<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-comment">{-
(c) The GRASP/AQUA Project, Glasgow University, 1992-1998

\section{Tidying up Core}
-}</span><span>
</span><span id="line-6"></span><span>
</span><span id="line-7"></span><span class="hs-pragma">{-# LANGUAGE CPP, DeriveFunctor, ViewPatterns #-}</span><span>
</span><span id="line-8"></span><span>
</span><span id="line-9"></span><span class="hs-pragma">{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}</span><span>
</span><span id="line-10"></span><span>
</span><span id="line-11"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.Iface.Tidy</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-12"></span><span>       </span><span class="annot"><a href="GHC.Iface.Tidy.html#mkBootModDetailsTc"><span class="hs-identifier">mkBootModDetailsTc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Iface.Tidy.html#tidyProgram"><span class="hs-identifier">tidyProgram</span></a></span><span>
</span><span id="line-13"></span><span>   </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span class="hs-cpp">

#include &quot;HsVersions.h&quot;
</span><span>
</span><span id="line-17"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span>
</span><span id="line-18"></span><span>
</span><span id="line-19"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html"><span class="hs-identifier">GHC.Tc.Types</span></a></span><span>
</span><span id="line-20"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html"><span class="hs-identifier">GHC.Driver.Session</span></a></span><span>
</span><span id="line-21"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.html"><span class="hs-identifier">GHC.Core</span></a></span><span>
</span><span id="line-22"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Unfold.html"><span class="hs-identifier">GHC.Core.Unfold</span></a></span><span>
</span><span id="line-23"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.FVs.html"><span class="hs-identifier">GHC.Core.FVs</span></a></span><span>
</span><span id="line-24"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Tidy.html"><span class="hs-identifier">GHC.Core.Tidy</span></a></span><span>
</span><span id="line-25"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Monad.html"><span class="hs-identifier">GHC.Core.Opt.Monad</span></a></span><span>
</span><span id="line-26"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Stats.html"><span class="hs-identifier">GHC.Core.Stats</span></a></span><span>   </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Stats.html#coreBindsStats"><span class="hs-identifier">coreBindsStats</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Stats.html#CoreStats"><span class="hs-identifier">CoreStats</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-27"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Seq.html"><span class="hs-identifier">GHC.Core.Seq</span></a></span><span>     </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.Seq.html#seqBinds"><span class="hs-identifier">seqBinds</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-28"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Lint.html"><span class="hs-identifier">GHC.Core.Lint</span></a></span><span>
</span><span id="line-29"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Rules.html"><span class="hs-identifier">GHC.Core.Rules</span></a></span><span>
</span><span id="line-30"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.PatSyn.html"><span class="hs-identifier">GHC.Core.PatSyn</span></a></span><span>
</span><span id="line-31"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.ConLike.html"><span class="hs-identifier">GHC.Core.ConLike</span></a></span><span>
</span><span id="line-32"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html"><span class="hs-identifier">GHC.Core.Opt.Arity</span></a></span><span>   </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#exprArity"><span class="hs-identifier">exprArity</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Opt.Arity.html#exprBotStrictness_maybe"><span class="hs-identifier">exprBotStrictness_maybe</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-33"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Iface.Tidy.StaticPtrTable.html"><span class="hs-identifier">GHC.Iface.Tidy.StaticPtrTable</span></a></span><span>
</span><span id="line-34"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html"><span class="hs-identifier">GHC.Types.Var.Env</span></a></span><span>
</span><span id="line-35"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html"><span class="hs-identifier">GHC.Types.Var.Set</span></a></span><span>
</span><span id="line-36"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.html"><span class="hs-identifier">GHC.Types.Var</span></a></span><span>
</span><span id="line-37"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Id.html"><span class="hs-identifier">GHC.Types.Id</span></a></span><span>
</span><span id="line-38"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Id.Make.html"><span class="hs-identifier">GHC.Types.Id.Make</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Types.Id.Make.html#mkDictSelRhs"><span class="hs-identifier">mkDictSelRhs</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-39"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Id.Info.html"><span class="hs-identifier">GHC.Types.Id.Info</span></a></span><span>
</span><span id="line-40"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.InstEnv.html"><span class="hs-identifier">GHC.Core.InstEnv</span></a></span><span>
</span><span id="line-41"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Type.html"><span class="hs-identifier">GHC.Core.Type</span></a></span><span>     </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Tidy.html#tidyTopType"><span class="hs-identifier">tidyTopType</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-42"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Demand.html"><span class="hs-identifier">GHC.Types.Demand</span></a></span><span>  </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Types.Demand.html#appIsDeadEnd"><span class="hs-identifier">appIsDeadEnd</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Demand.html#isTopSig"><span class="hs-identifier">isTopSig</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Demand.html#isDeadEndSig"><span class="hs-identifier">isDeadEndSig</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-43"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Cpr.html"><span class="hs-identifier">GHC.Types.Cpr</span></a></span><span>     </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Types.Cpr.html#mkCprSig"><span class="hs-identifier">mkCprSig</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Cpr.html#botCpr"><span class="hs-identifier">botCpr</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-44"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html"><span class="hs-identifier">GHC.Types.Basic</span></a></span><span>
</span><span id="line-45"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Name.html"><span class="hs-identifier">GHC.Types.Name</span></a></span><span> </span><span class="hs-keyword">hiding</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Name.Occurrence.html#varName"><span class="hs-identifier">varName</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-46"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Name.Set.html"><span class="hs-identifier">GHC.Types.Name.Set</span></a></span><span>
</span><span id="line-47"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Name.Cache.html"><span class="hs-identifier">GHC.Types.Name.Cache</span></a></span><span>
</span><span id="line-48"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Avail.html"><span class="hs-identifier">GHC.Types.Avail</span></a></span><span>
</span><span id="line-49"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Iface.Env.html"><span class="hs-identifier">GHC.Iface.Env</span></a></span><span>
</span><span id="line-50"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html"><span class="hs-identifier">GHC.Tc.Utils.Env</span></a></span><span>
</span><span id="line-51"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Monad.html"><span class="hs-identifier">GHC.Tc.Utils.Monad</span></a></span><span>
</span><span id="line-52"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.DataCon.html"><span class="hs-identifier">GHC.Core.DataCon</span></a></span><span>
</span><span id="line-53"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html"><span class="hs-identifier">GHC.Core.TyCon</span></a></span><span>
</span><span id="line-54"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Class.html"><span class="hs-identifier">GHC.Core.Class</span></a></span><span>
</span><span id="line-55"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Unit.Module.html"><span class="hs-identifier">GHC.Unit.Module</span></a></span><span>
</span><span id="line-56"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Driver.Types.html"><span class="hs-identifier">GHC.Driver.Types</span></a></span><span>
</span><span id="line-57"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.Maybe.html"><span class="hs-identifier">GHC.Data.Maybe</span></a></span><span>
</span><span id="line-58"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Unique.Supply.html"><span class="hs-identifier">GHC.Types.Unique.Supply</span></a></span><span>
</span><span id="line-59"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html"><span class="hs-identifier">GHC.Utils.Outputable</span></a></span><span>
</span><span id="line-60"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html"><span class="hs-identifier">GHC.Utils.Misc</span></a></span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html#filterOut"><span class="hs-identifier">filterOut</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-61"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="GHC.Utils.Error.html"><span class="hs-identifier">GHC.Utils.Error</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Err</span></span><span>
</span><span id="line-62"></span><span>
</span><span id="line-63"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.html#"><span class="hs-identifier">Control.Monad</span></a></span><span>
</span><span id="line-64"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Function.html#"><span class="hs-identifier">Data.Function</span></a></span><span>
</span><span id="line-65"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.List.html#"><span class="hs-identifier">Data.List</span></a></span><span>        </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/Data.OldList.html#sortBy"><span class="hs-identifier">sortBy</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Data.Traversable.html#mapAccumL"><span class="hs-identifier">mapAccumL</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-66"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.IORef.html#"><span class="hs-identifier">Data.IORef</span></a></span><span>       </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/GHC.IORef.html#atomicModifyIORef%27"><span class="hs-identifier">atomicModifyIORef'</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-67"></span><span>
</span><span id="line-68"></span><span class="hs-comment">{-
Constructing the TypeEnv, Instances, Rules from which the
ModIface is constructed, and which goes on to subsequent modules in
--make mode.

Most of the interface file is obtained simply by serialising the
TypeEnv.  One important consequence is that if the *interface file*
has pragma info if and only if the final TypeEnv does. This is not so
important for *this* module, but it's essential for ghc --make:
subsequent compilations must not see (e.g.) the arity if the interface
file does not contain arity If they do, they'll exploit the arity;
then the arity might change, but the iface file doesn't change =&gt;
recompilation does not happen =&gt; disaster.

For data types, the final TypeEnv will have a TyThing for the TyCon,
plus one for each DataCon; the interface file will contain just one
data type declaration, but it is de-serialised back into a collection
of TyThings.

************************************************************************
*                                                                      *
                Plan A: simpleTidyPgm
*                                                                      *
************************************************************************


Plan A: mkBootModDetails: omit pragmas, make interfaces small
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Ignore the bindings

* Drop all WiredIn things from the TypeEnv
        (we never want them in interface files)

* Retain all TyCons and Classes in the TypeEnv, to avoid
        having to find which ones are mentioned in the
        types of exported Ids

* Trim off the constructors of non-exported TyCons, both
        from the TyCon and from the TypeEnv

* Drop non-exported Ids from the TypeEnv

* Tidy the types of the DFunIds of Instances,
  make them into GlobalIds, (they already have External Names)
  and add them to the TypeEnv

* Tidy the types of the (exported) Ids in the TypeEnv,
  make them into GlobalIds (they already have External Names)

* Drop rules altogether

* Tidy the bindings, to ensure that the Arity
  information is correct for each top-level binder; the
  code generator needs it. And to ensure that local names have
  distinct OccNames in case of object-file splitting

* If this an hsig file, drop the instances altogether too (they'll
  get pulled in by the implicit module import.
-}</span><span>
</span><span id="line-127"></span><span>
</span><span id="line-128"></span><span class="hs-comment">-- This is Plan A: make a small type env when typechecking only,</span><span>
</span><span id="line-129"></span><span class="hs-comment">-- or when compiling a hs-boot file, or simply when not using -O</span><span>
</span><span id="line-130"></span><span class="hs-comment">--</span><span>
</span><span id="line-131"></span><span class="hs-comment">-- We don't look at the bindings at all -- there aren't any</span><span>
</span><span id="line-132"></span><span class="hs-comment">-- for hs-boot files</span><span>
</span><span id="line-133"></span><span>
</span><span id="line-134"></span><span class="annot"><a href="GHC.Iface.Tidy.html#mkBootModDetailsTc"><span class="hs-identifier hs-type">mkBootModDetailsTc</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Types.html#HscEnv"><span class="hs-identifier hs-type">HscEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcGblEnv"><span class="hs-identifier hs-type">TcGblEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="GHC.Driver.Types.html#ModDetails"><span class="hs-identifier hs-type">ModDetails</span></a></span><span>
</span><span id="line-135"></span><span id="mkBootModDetailsTc"><span class="annot"><span class="annottext">mkBootModDetailsTc :: HscEnv -&gt; TcGblEnv -&gt; IO ModDetails
</span><a href="GHC.Iface.Tidy.html#mkBootModDetailsTc"><span class="hs-identifier hs-var hs-var">mkBootModDetailsTc</span></a></span></span><span> </span><span id="local-6989586621681181327"><span class="annot"><span class="annottext">HscEnv
</span><a href="#local-6989586621681181327"><span class="hs-identifier hs-var">hsc_env</span></a></span></span><span>
</span><span id="line-136"></span><span>        </span><span class="annot"><a href="GHC.Tc.Types.html#TcGblEnv"><span class="hs-identifier hs-type">TcGblEnv</span></a></span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">tcg_exports :: TcGblEnv -&gt; [AvailInfo]
</span><a href="GHC.Tc.Types.html#tcg_exports"><span class="hs-identifier hs-var">tcg_exports</span></a></span><span>          </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681181324"><span class="annot"><span class="annottext">[AvailInfo]
</span><a href="#local-6989586621681181324"><span class="hs-identifier hs-var">exports</span></a></span></span><span class="hs-special">,</span><span>
</span><span id="line-137"></span><span>                  </span><span class="annot"><span class="annottext">tcg_type_env :: TcGblEnv -&gt; TypeEnv
</span><a href="GHC.Tc.Types.html#tcg_type_env"><span class="hs-identifier hs-var">tcg_type_env</span></a></span><span>         </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681181322"><span class="annot"><span class="annottext">TypeEnv
</span><a href="#local-6989586621681181322"><span class="hs-identifier hs-var">type_env</span></a></span></span><span class="hs-special">,</span><span> </span><span class="hs-comment">-- just for the Ids</span><span>
</span><span id="line-138"></span><span>                  </span><span class="annot"><span class="annottext">tcg_tcs :: TcGblEnv -&gt; [TyCon]
</span><a href="GHC.Tc.Types.html#tcg_tcs"><span class="hs-identifier hs-var">tcg_tcs</span></a></span><span>              </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681181320"><span class="annot"><span class="annottext">[TyCon]
</span><a href="#local-6989586621681181320"><span class="hs-identifier hs-var">tcs</span></a></span></span><span class="hs-special">,</span><span>
</span><span id="line-139"></span><span>                  </span><span class="annot"><span class="annottext">tcg_patsyns :: TcGblEnv -&gt; [PatSyn]
</span><a href="GHC.Tc.Types.html#tcg_patsyns"><span class="hs-identifier hs-var">tcg_patsyns</span></a></span><span>          </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681181318"><span class="annot"><span class="annottext">[PatSyn]
</span><a href="#local-6989586621681181318"><span class="hs-identifier hs-var">pat_syns</span></a></span></span><span class="hs-special">,</span><span>
</span><span id="line-140"></span><span>                  </span><span class="annot"><span class="annottext">tcg_insts :: TcGblEnv -&gt; [ClsInst]
</span><a href="GHC.Tc.Types.html#tcg_insts"><span class="hs-identifier hs-var">tcg_insts</span></a></span><span>            </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681181316"><span class="annot"><span class="annottext">[ClsInst]
</span><a href="#local-6989586621681181316"><span class="hs-identifier hs-var">insts</span></a></span></span><span class="hs-special">,</span><span>
</span><span id="line-141"></span><span>                  </span><span class="annot"><span class="annottext">tcg_fam_insts :: TcGblEnv -&gt; [FamInst]
</span><a href="GHC.Tc.Types.html#tcg_fam_insts"><span class="hs-identifier hs-var">tcg_fam_insts</span></a></span><span>        </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681181314"><span class="annot"><span class="annottext">[FamInst]
</span><a href="#local-6989586621681181314"><span class="hs-identifier hs-var">fam_insts</span></a></span></span><span class="hs-special">,</span><span>
</span><span id="line-142"></span><span>                  </span><span class="annot"><span class="annottext">tcg_complete_matches :: TcGblEnv -&gt; [CompleteMatch]
</span><a href="GHC.Tc.Types.html#tcg_complete_matches"><span class="hs-identifier hs-var">tcg_complete_matches</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681181312"><span class="annot"><span class="annottext">[CompleteMatch]
</span><a href="#local-6989586621681181312"><span class="hs-identifier hs-var">complete_sigs</span></a></span></span><span class="hs-special">,</span><span>
</span><span id="line-143"></span><span>                  </span><span class="annot"><span class="annottext">tcg_mod :: TcGblEnv -&gt; Module
</span><a href="GHC.Tc.Types.html#tcg_mod"><span class="hs-identifier hs-var">tcg_mod</span></a></span><span>              </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681181310"><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681181310"><span class="hs-identifier hs-var">this_mod</span></a></span></span><span>
</span><span id="line-144"></span><span>                </span><span class="hs-special">}</span><span>
</span><span id="line-145"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-comment">-- This timing isn't terribly useful since the result isn't forced, but</span><span>
</span><span id="line-146"></span><span>    </span><span class="hs-comment">-- the message is useful to locating oneself in the compilation process.</span><span>
</span><span id="line-147"></span><span>    </span><span class="annot"><span class="annottext">DynFlags
-&gt; SDoc -&gt; (ModDetails -&gt; ()) -&gt; IO ModDetails -&gt; IO ModDetails
forall (m :: * -&gt; *) a.
MonadIO m =&gt;
DynFlags -&gt; SDoc -&gt; (a -&gt; ()) -&gt; m a -&gt; m a
</span><a href="GHC.Utils.Error.html#withTiming"><span class="hs-identifier hs-var">Err.withTiming</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681181308"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-148"></span><span>                   </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;CoreTidy&quot;</span></span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#brackets"><span class="hs-identifier hs-var">brackets</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Module -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681181310"><span class="hs-identifier hs-var">this_mod</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-149"></span><span>                   </span><span class="hs-special">(</span><span class="annot"><span class="annottext">() -&gt; ModDetails -&gt; ()
forall a b. a -&gt; b -&gt; a
</span><a href="../../base/src/GHC.Base.html#const"><span class="hs-identifier hs-var">const</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IO ModDetails -&gt; IO ModDetails) -&gt; IO ModDetails -&gt; IO ModDetails
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-150"></span><span>    </span><span class="annot"><span class="annottext">ModDetails -&gt; IO ModDetails
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ModDetails :: [AvailInfo]
-&gt; TypeEnv
-&gt; [ClsInst]
-&gt; [FamInst]
-&gt; [CoreRule]
-&gt; [Annotation]
-&gt; [CompleteMatch]
-&gt; ModDetails
</span><a href="GHC.Driver.Types.html#ModDetails"><span class="hs-identifier hs-type">ModDetails</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">md_types :: TypeEnv
</span><a href="GHC.Driver.Types.html#md_types"><span class="hs-identifier hs-var">md_types</span></a></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TypeEnv
</span><a href="#local-6989586621681181300"><span class="hs-identifier hs-var">type_env'</span></a></span><span>
</span><span id="line-151"></span><span>                       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">md_insts :: [ClsInst]
</span><a href="GHC.Driver.Types.html#md_insts"><span class="hs-identifier hs-var">md_insts</span></a></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[ClsInst]
</span><a href="#local-6989586621681181298"><span class="hs-identifier hs-var">insts'</span></a></span><span>
</span><span id="line-152"></span><span>                       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">md_fam_insts :: [FamInst]
</span><a href="GHC.Driver.Types.html#md_fam_insts"><span class="hs-identifier hs-var">md_fam_insts</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[FamInst]
</span><a href="#local-6989586621681181314"><span class="hs-identifier hs-var">fam_insts</span></a></span><span>
</span><span id="line-153"></span><span>                       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">md_rules :: [CoreRule]
</span><a href="GHC.Driver.Types.html#md_rules"><span class="hs-identifier hs-var">md_rules</span></a></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-154"></span><span>                       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">md_anns :: [Annotation]
</span><a href="GHC.Driver.Types.html#md_anns"><span class="hs-identifier hs-var">md_anns</span></a></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-155"></span><span>                       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">md_exports :: [AvailInfo]
</span><a href="GHC.Driver.Types.html#md_exports"><span class="hs-identifier hs-var">md_exports</span></a></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[AvailInfo]
</span><a href="#local-6989586621681181324"><span class="hs-identifier hs-var">exports</span></a></span><span>
</span><span id="line-156"></span><span>                       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">md_complete_sigs :: [CompleteMatch]
</span><a href="GHC.Driver.Types.html#md_complete_sigs"><span class="hs-identifier hs-var">md_complete_sigs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[CompleteMatch]
</span><a href="#local-6989586621681181312"><span class="hs-identifier hs-var">complete_sigs</span></a></span><span>
</span><span id="line-157"></span><span>                       </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-158"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-159"></span><span>    </span><span id="local-6989586621681181308"><span class="annot"><span class="annottext">dflags :: DynFlags
</span><a href="#local-6989586621681181308"><span class="hs-identifier hs-var hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HscEnv -&gt; DynFlags
</span><a href="GHC.Driver.Types.html#hsc_dflags"><span class="hs-identifier hs-var hs-var">hsc_dflags</span></a></span><span> </span><span class="annot"><span class="annottext">HscEnv
</span><a href="#local-6989586621681181327"><span class="hs-identifier hs-var">hsc_env</span></a></span><span>
</span><span id="line-160"></span><span>
</span><span id="line-161"></span><span>    </span><span class="hs-comment">-- Find the LocalIds in the type env that are exported</span><span>
</span><span id="line-162"></span><span>    </span><span class="hs-comment">-- Make them into GlobalIds, and tidy their types</span><span>
</span><span id="line-163"></span><span>    </span><span class="hs-comment">--</span><span>
</span><span id="line-164"></span><span>    </span><span class="hs-comment">-- It's very important to remove the non-exported ones</span><span>
</span><span id="line-165"></span><span>    </span><span class="hs-comment">-- because we don't tidy the OccNames, and if we don't remove</span><span>
</span><span id="line-166"></span><span>    </span><span class="hs-comment">-- the non-exported ones we'll get many things with the</span><span>
</span><span id="line-167"></span><span>    </span><span class="hs-comment">-- same name in the interface file, giving chaos.</span><span>
</span><span id="line-168"></span><span>    </span><span class="hs-comment">--</span><span>
</span><span id="line-169"></span><span>    </span><span class="hs-comment">-- Do make sure that we keep Ids that are already Global.</span><span>
</span><span id="line-170"></span><span>    </span><span class="hs-comment">-- When typechecking an .hs-boot file, the Ids come through as</span><span>
</span><span id="line-171"></span><span>    </span><span class="hs-comment">-- GlobalIds.</span><span>
</span><span id="line-172"></span><span>    </span><span id="local-6989586621681181291"><span class="annot"><span class="annottext">final_ids :: [Id]
</span><a href="#local-6989586621681181291"><span class="hs-identifier hs-var hs-var">final_ids</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Id
</span><a href="GHC.Iface.Tidy.html#globaliseAndTidyBootId"><span class="hs-identifier hs-var">globaliseAndTidyBootId</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181289"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-173"></span><span>                </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621681181289"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181289"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TypeEnv -&gt; [Id]
</span><a href="GHC.Driver.Types.html#typeEnvIds"><span class="hs-identifier hs-var">typeEnvIds</span></a></span><span> </span><span class="annot"><span class="annottext">TypeEnv
</span><a href="#local-6989586621681181322"><span class="hs-identifier hs-var">type_env</span></a></span><span>
</span><span id="line-174"></span><span>                </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="#local-6989586621681181287"><span class="hs-identifier hs-var">keep_it</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181289"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-175"></span><span>
</span><span id="line-176"></span><span>    </span><span id="local-6989586621681181284"><span class="annot"><span class="annottext">final_tcs :: [TyCon]
</span><a href="#local-6989586621681181284"><span class="hs-identifier hs-var hs-var">final_tcs</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TyCon -&gt; Bool) -&gt; [TyCon] -&gt; [TyCon]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="GHC.Utils.Misc.html#filterOut"><span class="hs-identifier hs-var">filterOut</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Bool
forall thing. NamedThing thing =&gt; thing -&gt; Bool
</span><a href="GHC.Types.Name.html#isWiredIn"><span class="hs-identifier hs-var">isWiredIn</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCon]
</span><a href="#local-6989586621681181320"><span class="hs-identifier hs-var">tcs</span></a></span><span>
</span><span id="line-177"></span><span>                 </span><span class="hs-comment">-- See Note [Drop wired-in things]</span><span>
</span><span id="line-178"></span><span>    </span><span id="local-6989586621681181282"><span class="annot"><span class="annottext">type_env1 :: TypeEnv
</span><a href="#local-6989586621681181282"><span class="hs-identifier hs-var hs-var">type_env1</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; [TyCon] -&gt; [FamInst] -&gt; TypeEnv
</span><a href="GHC.Driver.Types.html#typeEnvFromEntities"><span class="hs-identifier hs-var">typeEnvFromEntities</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681181291"><span class="hs-identifier hs-var">final_ids</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCon]
</span><a href="#local-6989586621681181284"><span class="hs-identifier hs-var">final_tcs</span></a></span><span> </span><span class="annot"><span class="annottext">[FamInst]
</span><a href="#local-6989586621681181314"><span class="hs-identifier hs-var">fam_insts</span></a></span><span>
</span><span id="line-179"></span><span>    </span><span id="local-6989586621681181298"><span class="annot"><span class="annottext">insts' :: [ClsInst]
</span><a href="#local-6989586621681181298"><span class="hs-identifier hs-var hs-var">insts'</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TypeEnv -&gt; [ClsInst] -&gt; [ClsInst]
</span><a href="GHC.Iface.Tidy.html#mkFinalClsInsts"><span class="hs-identifier hs-var">mkFinalClsInsts</span></a></span><span> </span><span class="annot"><span class="annottext">TypeEnv
</span><a href="#local-6989586621681181282"><span class="hs-identifier hs-var">type_env1</span></a></span><span> </span><span class="annot"><span class="annottext">[ClsInst]
</span><a href="#local-6989586621681181316"><span class="hs-identifier hs-var">insts</span></a></span><span>
</span><span id="line-180"></span><span>    </span><span id="local-6989586621681181279"><span class="annot"><span class="annottext">pat_syns' :: [PatSyn]
</span><a href="#local-6989586621681181279"><span class="hs-identifier hs-var hs-var">pat_syns'</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TypeEnv -&gt; [PatSyn] -&gt; [PatSyn]
</span><a href="GHC.Iface.Tidy.html#mkFinalPatSyns"><span class="hs-identifier hs-var">mkFinalPatSyns</span></a></span><span>  </span><span class="annot"><span class="annottext">TypeEnv
</span><a href="#local-6989586621681181282"><span class="hs-identifier hs-var">type_env1</span></a></span><span> </span><span class="annot"><span class="annottext">[PatSyn]
</span><a href="#local-6989586621681181318"><span class="hs-identifier hs-var">pat_syns</span></a></span><span>
</span><span id="line-181"></span><span>    </span><span id="local-6989586621681181300"><span class="annot"><span class="annottext">type_env' :: TypeEnv
</span><a href="#local-6989586621681181300"><span class="hs-identifier hs-var hs-var">type_env'</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[PatSyn] -&gt; TypeEnv -&gt; TypeEnv
</span><a href="GHC.Iface.Tidy.html#extendTypeEnvWithPatSyns"><span class="hs-identifier hs-var">extendTypeEnvWithPatSyns</span></a></span><span> </span><span class="annot"><span class="annottext">[PatSyn]
</span><a href="#local-6989586621681181279"><span class="hs-identifier hs-var">pat_syns'</span></a></span><span> </span><span class="annot"><span class="annottext">TypeEnv
</span><a href="#local-6989586621681181282"><span class="hs-identifier hs-var">type_env1</span></a></span><span>
</span><span id="line-182"></span><span>
</span><span id="line-183"></span><span>    </span><span class="hs-comment">-- Default methods have their export flag set (isExportedId),</span><span>
</span><span id="line-184"></span><span>    </span><span class="hs-comment">-- but everything else doesn't (yet), because this is</span><span>
</span><span id="line-185"></span><span>    </span><span class="hs-comment">-- pre-desugaring, so we must test against the exports too.</span><span>
</span><span id="line-186"></span><span>    </span><span id="local-6989586621681181287"><span class="annot"><span class="annottext">keep_it :: Id -&gt; Bool
</span><a href="#local-6989586621681181287"><span class="hs-identifier hs-var hs-var">keep_it</span></a></span></span><span> </span><span id="local-6989586621681181276"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181276"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Name -&gt; Bool
</span><a href="GHC.Types.Name.html#isWiredInName"><span class="hs-identifier hs-var">isWiredInName</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681181274"><span class="hs-identifier hs-var">id_name</span></a></span><span>           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-187"></span><span>                 </span><span class="hs-comment">-- See Note [Drop wired-in things]</span><span>
</span><span id="line-188"></span><span>               </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Var.html#isExportedId"><span class="hs-identifier hs-var">isExportedId</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181276"><span class="hs-identifier hs-var">id</span></a></span><span>                 </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-189"></span><span>               </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681181274"><span class="hs-identifier hs-var">id_name</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; NameSet -&gt; Bool
</span><a href="GHC.Types.Name.Set.html#elemNameSet"><span class="hs-operator hs-var">`elemNameSet`</span></a></span><span> </span><span class="annot"><span class="annottext">NameSet
</span><a href="#local-6989586621681181271"><span class="hs-identifier hs-var">exp_names</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-190"></span><span>               </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>                       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-191"></span><span>               </span><span class="hs-keyword">where</span><span>
</span><span id="line-192"></span><span>                 </span><span id="local-6989586621681181274"><span class="annot"><span class="annottext">id_name :: Name
</span><a href="#local-6989586621681181274"><span class="hs-identifier hs-var hs-var">id_name</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Name
</span><a href="GHC.Types.Id.html#idName"><span class="hs-identifier hs-var">idName</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181276"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-193"></span><span>
</span><span id="line-194"></span><span>    </span><span id="local-6989586621681181271"><span class="annot"><span class="annottext">exp_names :: NameSet
</span><a href="#local-6989586621681181271"><span class="hs-identifier hs-var hs-var">exp_names</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[AvailInfo] -&gt; NameSet
</span><a href="GHC.Types.Avail.html#availsToNameSet"><span class="hs-identifier hs-var">availsToNameSet</span></a></span><span> </span><span class="annot"><span class="annottext">[AvailInfo]
</span><a href="#local-6989586621681181324"><span class="hs-identifier hs-var">exports</span></a></span><span>
</span><span id="line-195"></span><span>
</span><span id="line-196"></span><span class="annot"><a href="GHC.Iface.Tidy.html#lookupFinalId"><span class="hs-identifier hs-type">lookupFinalId</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Types.html#TypeEnv"><span class="hs-identifier hs-type">TypeEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span>
</span><span id="line-197"></span><span id="lookupFinalId"><span class="annot"><span class="annottext">lookupFinalId :: TypeEnv -&gt; Id -&gt; Id
</span><a href="GHC.Iface.Tidy.html#lookupFinalId"><span class="hs-identifier hs-var hs-var">lookupFinalId</span></a></span></span><span> </span><span id="local-6989586621681181267"><span class="annot"><span class="annottext">TypeEnv
</span><a href="#local-6989586621681181267"><span class="hs-identifier hs-var">type_env</span></a></span></span><span> </span><span id="local-6989586621681181266"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181266"><span class="hs-identifier hs-var">id</span></a></span></span><span>
</span><span id="line-198"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">TypeEnv -&gt; Name -&gt; Maybe TyThing
</span><a href="GHC.Driver.Types.html#lookupTypeEnv"><span class="hs-identifier hs-var">lookupTypeEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TypeEnv
</span><a href="#local-6989586621681181267"><span class="hs-identifier hs-var">type_env</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Name
</span><a href="GHC.Types.Id.html#idName"><span class="hs-identifier hs-var">idName</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181266"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-199"></span><span>      </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#AnId"><span class="hs-identifier hs-type">AnId</span></a></span><span> </span><span id="local-6989586621681181263"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181263"><span class="hs-identifier hs-var">id'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181263"><span class="hs-identifier hs-var">id'</span></a></span><span>
</span><span id="line-200"></span><span>      </span><span class="annot"><span class="annottext">Maybe TyThing
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; Id
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;lookup_final_id&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181266"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-201"></span><span>
</span><span id="line-202"></span><span class="annot"><a href="GHC.Iface.Tidy.html#mkFinalClsInsts"><span class="hs-identifier hs-type">mkFinalClsInsts</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Types.html#TypeEnv"><span class="hs-identifier hs-type">TypeEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.InstEnv.html#ClsInst"><span class="hs-identifier hs-type">ClsInst</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.InstEnv.html#ClsInst"><span class="hs-identifier hs-type">ClsInst</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-203"></span><span id="mkFinalClsInsts"><span class="annot"><span class="annottext">mkFinalClsInsts :: TypeEnv -&gt; [ClsInst] -&gt; [ClsInst]
</span><a href="GHC.Iface.Tidy.html#mkFinalClsInsts"><span class="hs-identifier hs-var hs-var">mkFinalClsInsts</span></a></span></span><span> </span><span id="local-6989586621681181261"><span class="annot"><span class="annottext">TypeEnv
</span><a href="#local-6989586621681181261"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(ClsInst -&gt; ClsInst) -&gt; [ClsInst] -&gt; [ClsInst]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Id -&gt; Id) -&gt; ClsInst -&gt; ClsInst
</span><a href="GHC.Core.InstEnv.html#updateClsInstDFun"><span class="hs-identifier hs-var">updateClsInstDFun</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TypeEnv -&gt; Id -&gt; Id
</span><a href="GHC.Iface.Tidy.html#lookupFinalId"><span class="hs-identifier hs-var">lookupFinalId</span></a></span><span> </span><span class="annot"><span class="annottext">TypeEnv
</span><a href="#local-6989586621681181261"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-204"></span><span>
</span><span id="line-205"></span><span class="annot"><a href="GHC.Iface.Tidy.html#mkFinalPatSyns"><span class="hs-identifier hs-type">mkFinalPatSyns</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Types.html#TypeEnv"><span class="hs-identifier hs-type">TypeEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.PatSyn.html#PatSyn"><span class="hs-identifier hs-type">PatSyn</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.PatSyn.html#PatSyn"><span class="hs-identifier hs-type">PatSyn</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-206"></span><span id="mkFinalPatSyns"><span class="annot"><span class="annottext">mkFinalPatSyns :: TypeEnv -&gt; [PatSyn] -&gt; [PatSyn]
</span><a href="GHC.Iface.Tidy.html#mkFinalPatSyns"><span class="hs-identifier hs-var hs-var">mkFinalPatSyns</span></a></span></span><span> </span><span id="local-6989586621681181259"><span class="annot"><span class="annottext">TypeEnv
</span><a href="#local-6989586621681181259"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(PatSyn -&gt; PatSyn) -&gt; [PatSyn] -&gt; [PatSyn]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Id -&gt; Id) -&gt; PatSyn -&gt; PatSyn
</span><a href="GHC.Core.PatSyn.html#updatePatSynIds"><span class="hs-identifier hs-var">updatePatSynIds</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TypeEnv -&gt; Id -&gt; Id
</span><a href="GHC.Iface.Tidy.html#lookupFinalId"><span class="hs-identifier hs-var">lookupFinalId</span></a></span><span> </span><span class="annot"><span class="annottext">TypeEnv
</span><a href="#local-6989586621681181259"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-207"></span><span>
</span><span id="line-208"></span><span class="annot"><a href="GHC.Iface.Tidy.html#extendTypeEnvWithPatSyns"><span class="hs-identifier hs-type">extendTypeEnvWithPatSyns</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.PatSyn.html#PatSyn"><span class="hs-identifier hs-type">PatSyn</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Driver.Types.html#TypeEnv"><span class="hs-identifier hs-type">TypeEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Driver.Types.html#TypeEnv"><span class="hs-identifier hs-type">TypeEnv</span></a></span><span>
</span><span id="line-209"></span><span id="extendTypeEnvWithPatSyns"><span class="annot"><span class="annottext">extendTypeEnvWithPatSyns :: [PatSyn] -&gt; TypeEnv -&gt; TypeEnv
</span><a href="GHC.Iface.Tidy.html#extendTypeEnvWithPatSyns"><span class="hs-identifier hs-var hs-var">extendTypeEnvWithPatSyns</span></a></span></span><span> </span><span id="local-6989586621681181257"><span class="annot"><span class="annottext">[PatSyn]
</span><a href="#local-6989586621681181257"><span class="hs-identifier hs-var">tidy_patsyns</span></a></span></span><span> </span><span id="local-6989586621681181256"><span class="annot"><span class="annottext">TypeEnv
</span><a href="#local-6989586621681181256"><span class="hs-identifier hs-var">type_env</span></a></span></span><span>
</span><span id="line-210"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TypeEnv -&gt; [TyThing] -&gt; TypeEnv
</span><a href="GHC.Driver.Types.html#extendTypeEnvList"><span class="hs-identifier hs-var">extendTypeEnvList</span></a></span><span> </span><span class="annot"><span class="annottext">TypeEnv
</span><a href="#local-6989586621681181256"><span class="hs-identifier hs-var">type_env</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">ConLike -&gt; TyThing
</span><a href="GHC.Core.TyCo.Rep.html#AConLike"><span class="hs-identifier hs-var">AConLike</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PatSyn -&gt; ConLike
</span><a href="GHC.Core.ConLike.html#PatSynCon"><span class="hs-identifier hs-var">PatSynCon</span></a></span><span> </span><span class="annot"><span class="annottext">PatSyn
</span><a href="#local-6989586621681181252"><span class="hs-identifier hs-var">ps</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621681181252"><span class="annot"><span class="annottext">PatSyn
</span><a href="#local-6989586621681181252"><span class="hs-identifier hs-var">ps</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[PatSyn]
</span><a href="#local-6989586621681181257"><span class="hs-identifier hs-var">tidy_patsyns</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-211"></span><span>
</span><span id="line-212"></span><span class="annot"><a href="GHC.Iface.Tidy.html#globaliseAndTidyBootId"><span class="hs-identifier hs-type">globaliseAndTidyBootId</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span>
</span><span id="line-213"></span><span class="hs-comment">-- For a LocalId with an External Name,</span><span>
</span><span id="line-214"></span><span class="hs-comment">-- makes it into a GlobalId</span><span>
</span><span id="line-215"></span><span class="hs-comment">--     * unchanged Name (might be Internal or External)</span><span>
</span><span id="line-216"></span><span class="hs-comment">--     * unchanged details</span><span>
</span><span id="line-217"></span><span class="hs-comment">--     * VanillaIdInfo (makes a conservative assumption about arity)</span><span>
</span><span id="line-218"></span><span class="hs-comment">--     * BootUnfolding (see Note [Inlining and hs-boot files] in GHC.CoreToIface)</span><span>
</span><span id="line-219"></span><span id="globaliseAndTidyBootId"><span class="annot"><span class="annottext">globaliseAndTidyBootId :: Id -&gt; Id
</span><a href="GHC.Iface.Tidy.html#globaliseAndTidyBootId"><span class="hs-identifier hs-var hs-var">globaliseAndTidyBootId</span></a></span></span><span> </span><span id="local-6989586621681181251"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181251"><span class="hs-identifier hs-var">id</span></a></span></span><span>
</span><span id="line-220"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Type -&gt; Type) -&gt; Id -&gt; Id
</span><a href="GHC.Types.Var.html#updateIdTypeAndMult"><span class="hs-identifier hs-var">updateIdTypeAndMult</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; Type
</span><a href="GHC.Core.TyCo.Tidy.html#tidyTopType"><span class="hs-identifier hs-var">tidyTopType</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Id
</span><a href="GHC.Types.Var.html#globaliseId"><span class="hs-identifier hs-var">globaliseId</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181251"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-221"></span><span>                   </span><span class="annot"><span class="annottext">Id -&gt; Unfolding -&gt; Id
</span><a href="GHC.Types.Id.html#setIdUnfolding"><span class="hs-operator hs-var">`setIdUnfolding`</span></a></span><span> </span><span class="annot"><span class="annottext">Unfolding
</span><a href="GHC.Core.html#BootUnfolding"><span class="hs-identifier hs-var">BootUnfolding</span></a></span><span>
</span><span id="line-222"></span><span>
</span><span id="line-223"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
        Plan B: tidy bindings, make TypeEnv full of IdInfo
*                                                                      *
************************************************************************

Plan B: include pragmas, make interfaces
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Step 1: Figure out which Ids are externally visible
          See Note [Choosing external Ids]

* Step 2: Gather the externally visible rules, separately from
          the top-level bindings.
          See Note [Finding external rules]

* Step 3: Tidy the bindings, externalising appropriate Ids
          See Note [Tidy the top-level bindings]

* Drop all Ids from the TypeEnv, and add all the External Ids from
  the bindings.  (This adds their IdInfo to the TypeEnv; and adds
  floated-out Ids that weren't even in the TypeEnv before.)

Note [Choosing external Ids]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
See also the section &quot;Interface stability&quot; in the
recompilation-avoidance commentary:
  https://gitlab.haskell.org/ghc/ghc/wikis/commentary/compiler/recompilation-avoidance

First we figure out which Ids are &quot;external&quot; Ids.  An
&quot;external&quot; Id is one that is visible from outside the compilation
unit.  These are
  a) the user exported ones
  b) the ones bound to static forms
  c) ones mentioned in the unfoldings, workers, or
     rules of externally-visible ones

While figuring out which Ids are external, we pick a &quot;tidy&quot; OccName
for each one.  That is, we make its OccName distinct from the other
external OccNames in this module, so that in interface files and
object code we can refer to it unambiguously by its OccName.  The
OccName for each binder is prefixed by the name of the exported Id
that references it; e.g. if &quot;f&quot; references &quot;x&quot; in its unfolding, then
&quot;x&quot; is renamed to &quot;f_x&quot;.  This helps distinguish the different &quot;x&quot;s
from each other, and means that if &quot;f&quot; is later removed, things that
depend on the other &quot;x&quot;s will not need to be recompiled.  Of course,
if there are multiple &quot;f_x&quot;s, then we have to disambiguate somehow; we
use &quot;f_x0&quot;, &quot;f_x1&quot; etc.

As far as possible we should assign names in a deterministic fashion.
Each time this module is compiled with the same options, we should end
up with the same set of external names with the same types.  That is,
the ABI hash in the interface should not change.  This turns out to be
quite tricky, since the order of the bindings going into the tidy
phase is already non-deterministic, as it is based on the ordering of
Uniques, which are assigned unpredictably.

To name things in a stable way, we do a depth-first-search of the
bindings, starting from the exports sorted by name.  This way, as long
as the bindings themselves are deterministic (they sometimes aren't!),
the order in which they are presented to the tidying phase does not
affect the names we assign.

Note [Tidy the top-level bindings]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Next we traverse the bindings top to bottom.  For each *top-level*
binder

 1. Make it into a GlobalId; its IdDetails becomes VanillaGlobal,
    reflecting the fact that from now on we regard it as a global,
    not local, Id

 2. Give it a system-wide Unique.
    [Even non-exported things need system-wide Uniques because the
    byte-code generator builds a single Name-&gt;BCO symbol table.]

    We use the NameCache kept in the HscEnv as the
    source of such system-wide uniques.

    For external Ids, use the original-name cache in the NameCache
    to ensure that the unique assigned is the same as the Id had
    in any previous compilation run.

 3. Rename top-level Ids according to the names we chose in step 1.
    If it's an external Id, make it have a External Name, otherwise
    make it have an Internal Name.  This is used by the code generator
    to decide whether to make the label externally visible

 4. Give it its UTTERLY FINAL IdInfo; in ptic,
        * its unfolding, if it should have one

        * its arity, computed from the number of visible lambdas


Finally, substitute these new top-level binders consistently
throughout, including in unfoldings.  We also tidy binders in
RHSs, so that they print nicely in interfaces.

Note [Always expose compulsory unfoldings]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We must make absolutely sure that unsafeCoerce# is inlined. You might
think that giving it a compulsory unfolding is enough. However,
unsafeCoerce# is put in an interface file just like any other definition.
So, unless we take special precuations
- If we compiled Unsafe.Coerce with -O0, we might not put the unfolding
  into the interface file.
- If we compile a module M, that imports Unsafe.Coerce, with -O0 we might
  not read the unfolding out of the interface file.

So we need to take care, to ensure that Compulsory unfoldings are written
and read.  That makes sense: they are compulsory, after all. There are
three places this is actioned:

* GHC.Iface.Tidy.addExternal.  Export end: expose compulsory
  unfoldings, even with -O0.

* GHC.IfaceToCore.tcIdInfo.  Import end: when reading in from
  interface file, even with -O0 (fignore-interface-pragmas.)  we must
  load a compulsory unfolding
-}</span><span>
</span><span id="line-343"></span><span>
</span><span id="line-344"></span><span class="annot"><a href="GHC.Iface.Tidy.html#tidyProgram"><span class="hs-identifier hs-type">tidyProgram</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Types.html#HscEnv"><span class="hs-identifier hs-type">HscEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Driver.Types.html#ModGuts"><span class="hs-identifier hs-type">ModGuts</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Driver.Types.html#CgGuts"><span class="hs-identifier hs-type">CgGuts</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Driver.Types.html#ModDetails"><span class="hs-identifier hs-type">ModDetails</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-345"></span><span id="tidyProgram"><span class="annot"><span class="annottext">tidyProgram :: HscEnv -&gt; ModGuts -&gt; IO (CgGuts, ModDetails)
</span><a href="GHC.Iface.Tidy.html#tidyProgram"><span class="hs-identifier hs-var hs-var">tidyProgram</span></a></span></span><span> </span><span id="local-6989586621681181246"><span class="annot"><span class="annottext">HscEnv
</span><a href="#local-6989586621681181246"><span class="hs-identifier hs-var">hsc_env</span></a></span></span><span>  </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Driver.Types.html#ModGuts"><span class="hs-identifier hs-type">ModGuts</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">mg_module :: ModGuts -&gt; Module
</span><a href="GHC.Driver.Types.html#mg_module"><span class="hs-identifier hs-var">mg_module</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681181243"><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681181243"><span class="hs-identifier hs-var">mod</span></a></span></span><span>
</span><span id="line-346"></span><span>                              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">mg_exports :: ModGuts -&gt; [AvailInfo]
</span><a href="GHC.Driver.Types.html#mg_exports"><span class="hs-identifier hs-var">mg_exports</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681181241"><span class="annot"><span class="annottext">[AvailInfo]
</span><a href="#local-6989586621681181241"><span class="hs-identifier hs-var">exports</span></a></span></span><span>
</span><span id="line-347"></span><span>                              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">mg_rdr_env :: ModGuts -&gt; GlobalRdrEnv
</span><a href="GHC.Driver.Types.html#mg_rdr_env"><span class="hs-identifier hs-var">mg_rdr_env</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681181239"><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681181239"><span class="hs-identifier hs-var">rdr_env</span></a></span></span><span>
</span><span id="line-348"></span><span>                              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">mg_tcs :: ModGuts -&gt; [TyCon]
</span><a href="GHC.Driver.Types.html#mg_tcs"><span class="hs-identifier hs-var">mg_tcs</span></a></span><span>       </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681181237"><span class="annot"><span class="annottext">[TyCon]
</span><a href="#local-6989586621681181237"><span class="hs-identifier hs-var">tcs</span></a></span></span><span>
</span><span id="line-349"></span><span>                              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">mg_insts :: ModGuts -&gt; [ClsInst]
</span><a href="GHC.Driver.Types.html#mg_insts"><span class="hs-identifier hs-var">mg_insts</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681181235"><span class="annot"><span class="annottext">[ClsInst]
</span><a href="#local-6989586621681181235"><span class="hs-identifier hs-var">cls_insts</span></a></span></span><span>
</span><span id="line-350"></span><span>                              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">mg_fam_insts :: ModGuts -&gt; [FamInst]
</span><a href="GHC.Driver.Types.html#mg_fam_insts"><span class="hs-identifier hs-var">mg_fam_insts</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681181233"><span class="annot"><span class="annottext">[FamInst]
</span><a href="#local-6989586621681181233"><span class="hs-identifier hs-var">fam_insts</span></a></span></span><span>
</span><span id="line-351"></span><span>                              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">mg_binds :: ModGuts -&gt; CoreProgram
</span><a href="GHC.Driver.Types.html#mg_binds"><span class="hs-identifier hs-var">mg_binds</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681181231"><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621681181231"><span class="hs-identifier hs-var">binds</span></a></span></span><span>
</span><span id="line-352"></span><span>                              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">mg_patsyns :: ModGuts -&gt; [PatSyn]
</span><a href="GHC.Driver.Types.html#mg_patsyns"><span class="hs-identifier hs-var">mg_patsyns</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681181229"><span class="annot"><span class="annottext">[PatSyn]
</span><a href="#local-6989586621681181229"><span class="hs-identifier hs-var">patsyns</span></a></span></span><span>
</span><span id="line-353"></span><span>                              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">mg_rules :: ModGuts -&gt; [CoreRule]
</span><a href="GHC.Driver.Types.html#mg_rules"><span class="hs-identifier hs-var">mg_rules</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681181227"><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621681181227"><span class="hs-identifier hs-var">imp_rules</span></a></span></span><span>
</span><span id="line-354"></span><span>                              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">mg_anns :: ModGuts -&gt; [Annotation]
</span><a href="GHC.Driver.Types.html#mg_anns"><span class="hs-identifier hs-var">mg_anns</span></a></span><span>      </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681181225"><span class="annot"><span class="annottext">[Annotation]
</span><a href="#local-6989586621681181225"><span class="hs-identifier hs-var">anns</span></a></span></span><span>
</span><span id="line-355"></span><span>                              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">mg_complete_sigs :: ModGuts -&gt; [CompleteMatch]
</span><a href="GHC.Driver.Types.html#mg_complete_sigs"><span class="hs-identifier hs-var">mg_complete_sigs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681181223"><span class="annot"><span class="annottext">[CompleteMatch]
</span><a href="#local-6989586621681181223"><span class="hs-identifier hs-var">complete_sigs</span></a></span></span><span>
</span><span id="line-356"></span><span>                              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">mg_deps :: ModGuts -&gt; Dependencies
</span><a href="GHC.Driver.Types.html#mg_deps"><span class="hs-identifier hs-var">mg_deps</span></a></span><span>      </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681181221"><span class="annot"><span class="annottext">Dependencies
</span><a href="#local-6989586621681181221"><span class="hs-identifier hs-var">deps</span></a></span></span><span>
</span><span id="line-357"></span><span>                              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">mg_foreign :: ModGuts -&gt; ForeignStubs
</span><a href="GHC.Driver.Types.html#mg_foreign"><span class="hs-identifier hs-var">mg_foreign</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681181219"><span class="annot"><span class="annottext">ForeignStubs
</span><a href="#local-6989586621681181219"><span class="hs-identifier hs-var">foreign_stubs</span></a></span></span><span>
</span><span id="line-358"></span><span>                              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">mg_foreign_files :: ModGuts -&gt; [(ForeignSrcLang, String)]
</span><a href="GHC.Driver.Types.html#mg_foreign_files"><span class="hs-identifier hs-var">mg_foreign_files</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681181217"><span class="annot"><span class="annottext">[(ForeignSrcLang, String)]
</span><a href="#local-6989586621681181217"><span class="hs-identifier hs-var">foreign_files</span></a></span></span><span>
</span><span id="line-359"></span><span>                              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">mg_hpc_info :: ModGuts -&gt; HpcInfo
</span><a href="GHC.Driver.Types.html#mg_hpc_info"><span class="hs-identifier hs-var">mg_hpc_info</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681181215"><span class="annot"><span class="annottext">HpcInfo
</span><a href="#local-6989586621681181215"><span class="hs-identifier hs-var">hpc_info</span></a></span></span><span>
</span><span id="line-360"></span><span>                              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">mg_modBreaks :: ModGuts -&gt; Maybe ModBreaks
</span><a href="GHC.Driver.Types.html#mg_modBreaks"><span class="hs-identifier hs-var">mg_modBreaks</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681181213"><span class="annot"><span class="annottext">Maybe ModBreaks
</span><a href="#local-6989586621681181213"><span class="hs-identifier hs-var">modBreaks</span></a></span></span><span>
</span><span id="line-361"></span><span>                              </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-362"></span><span>
</span><span id="line-363"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags
-&gt; SDoc
-&gt; ((CgGuts, ModDetails) -&gt; ())
-&gt; IO (CgGuts, ModDetails)
-&gt; IO (CgGuts, ModDetails)
forall (m :: * -&gt; *) a.
MonadIO m =&gt;
DynFlags -&gt; SDoc -&gt; (a -&gt; ()) -&gt; m a -&gt; m a
</span><a href="GHC.Utils.Error.html#withTiming"><span class="hs-identifier hs-var">Err.withTiming</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681181212"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-364"></span><span>                   </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;CoreTidy&quot;</span></span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#brackets"><span class="hs-identifier hs-var">brackets</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Module -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681181243"><span class="hs-identifier hs-var">mod</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-365"></span><span>                   </span><span class="hs-special">(</span><span class="annot"><span class="annottext">() -&gt; (CgGuts, ModDetails) -&gt; ()
forall a b. a -&gt; b -&gt; a
</span><a href="../../base/src/GHC.Base.html#const"><span class="hs-identifier hs-var">const</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IO (CgGuts, ModDetails) -&gt; IO (CgGuts, ModDetails))
-&gt; IO (CgGuts, ModDetails) -&gt; IO (CgGuts, ModDetails)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-366"></span><span>    </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681181211"><span class="annot"><span class="annottext">omit_prags :: Bool
</span><a href="#local-6989586621681181211"><span class="hs-identifier hs-var hs-var">omit_prags</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">GeneralFlag -&gt; DynFlags -&gt; Bool
</span><a href="GHC.Driver.Session.html#gopt"><span class="hs-identifier hs-var">gopt</span></a></span><span> </span><span class="annot"><span class="annottext">GeneralFlag
</span><a href="GHC.Driver.Flags.html#Opt_OmitInterfacePragmas"><span class="hs-identifier hs-var">Opt_OmitInterfacePragmas</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681181212"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-367"></span><span>              </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681181208"><span class="annot"><span class="annottext">expose_all :: Bool
</span><a href="#local-6989586621681181208"><span class="hs-identifier hs-var hs-var">expose_all</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">GeneralFlag -&gt; DynFlags -&gt; Bool
</span><a href="GHC.Driver.Session.html#gopt"><span class="hs-identifier hs-var">gopt</span></a></span><span> </span><span class="annot"><span class="annottext">GeneralFlag
</span><a href="GHC.Driver.Flags.html#Opt_ExposeAllUnfoldings"><span class="hs-identifier hs-var">Opt_ExposeAllUnfoldings</span></a></span><span>  </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681181212"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-368"></span><span>              </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681181206"><span class="annot"><span class="annottext">print_unqual :: PrintUnqualified
</span><a href="#local-6989586621681181206"><span class="hs-identifier hs-var hs-var">print_unqual</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; GlobalRdrEnv -&gt; PrintUnqualified
</span><a href="GHC.Driver.Types.html#mkPrintUnqualified"><span class="hs-identifier hs-var">mkPrintUnqualified</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681181212"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">GlobalRdrEnv
</span><a href="#local-6989586621681181239"><span class="hs-identifier hs-var">rdr_env</span></a></span><span>
</span><span id="line-369"></span><span>              </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681181203"><span class="annot"><span class="annottext">implicit_binds :: CoreProgram
</span><a href="#local-6989586621681181203"><span class="hs-identifier hs-var hs-var">implicit_binds</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TyCon -&gt; CoreProgram) -&gt; [TyCon] -&gt; CoreProgram
forall (t :: * -&gt; *) a b. Foldable t =&gt; (a -&gt; [b]) -&gt; t a -&gt; [b]
</span><a href="../../base/src/Data.Foldable.html#concatMap"><span class="hs-identifier hs-var">concatMap</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; CoreProgram
</span><a href="GHC.Iface.Tidy.html#getImplicitBinds"><span class="hs-identifier hs-var">getImplicitBinds</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCon]
</span><a href="#local-6989586621681181237"><span class="hs-identifier hs-var">tcs</span></a></span><span>
</span><span id="line-370"></span><span>              </span><span class="hs-special">}</span><span>
</span><span id="line-371"></span><span>
</span><span id="line-372"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681181200"><span class="annot"><span class="annottext">UnfoldEnv
</span><a href="#local-6989586621681181200"><span class="hs-identifier hs-var">unfold_env</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681181199"><span class="annot"><span class="annottext">TidyOccEnv
</span><a href="#local-6989586621681181199"><span class="hs-identifier hs-var">tidy_occ_env</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-373"></span><span>              </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">HscEnv
-&gt; Module
-&gt; Bool
-&gt; Bool
-&gt; CoreProgram
-&gt; CoreProgram
-&gt; [CoreRule]
-&gt; IO (UnfoldEnv, TidyOccEnv)
</span><a href="GHC.Iface.Tidy.html#chooseExternalIds"><span class="hs-identifier hs-var">chooseExternalIds</span></a></span><span> </span><span class="annot"><span class="annottext">HscEnv
</span><a href="#local-6989586621681181246"><span class="hs-identifier hs-var">hsc_env</span></a></span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681181243"><span class="hs-identifier hs-var">mod</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681181211"><span class="hs-identifier hs-var">omit_prags</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681181208"><span class="hs-identifier hs-var">expose_all</span></a></span><span>
</span><span id="line-374"></span><span>                                   </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621681181231"><span class="hs-identifier hs-var">binds</span></a></span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621681181203"><span class="hs-identifier hs-var">implicit_binds</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621681181227"><span class="hs-identifier hs-var">imp_rules</span></a></span><span>
</span><span id="line-375"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681181197"><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621681181197"><span class="hs-identifier hs-var">trimmed_binds</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681181196"><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621681181196"><span class="hs-identifier hs-var">trimmed_rules</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-376"></span><span>                    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
-&gt; CoreProgram
-&gt; [CoreRule]
-&gt; UnfoldEnv
-&gt; (CoreProgram, [CoreRule])
</span><a href="GHC.Iface.Tidy.html#findExternalRules"><span class="hs-identifier hs-var">findExternalRules</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681181211"><span class="hs-identifier hs-var">omit_prags</span></a></span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621681181231"><span class="hs-identifier hs-var">binds</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621681181227"><span class="hs-identifier hs-var">imp_rules</span></a></span><span> </span><span class="annot"><span class="annottext">UnfoldEnv
</span><a href="#local-6989586621681181200"><span class="hs-identifier hs-var">unfold_env</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-377"></span><span>
</span><span id="line-378"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681181194"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681181194"><span class="hs-identifier hs-var">tidy_env</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681181193"><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621681181193"><span class="hs-identifier hs-var">tidy_binds</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-379"></span><span>                 </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">HscEnv
-&gt; UnfoldEnv
-&gt; TidyOccEnv
-&gt; CoreProgram
-&gt; IO (TidyEnv, CoreProgram)
</span><a href="GHC.Iface.Tidy.html#tidyTopBinds"><span class="hs-identifier hs-var">tidyTopBinds</span></a></span><span> </span><span class="annot"><span class="annottext">HscEnv
</span><a href="#local-6989586621681181246"><span class="hs-identifier hs-var">hsc_env</span></a></span><span> </span><span class="annot"><span class="annottext">UnfoldEnv
</span><a href="#local-6989586621681181200"><span class="hs-identifier hs-var">unfold_env</span></a></span><span> </span><span class="annot"><span class="annottext">TidyOccEnv
</span><a href="#local-6989586621681181199"><span class="hs-identifier hs-var">tidy_occ_env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621681181197"><span class="hs-identifier hs-var">trimmed_binds</span></a></span><span>
</span><span id="line-380"></span><span>
</span><span id="line-381"></span><span>          </span><span class="hs-comment">-- See Note [Grand plan for static forms] in GHC.Iface.Tidy.StaticPtrTable.</span><span>
</span><span id="line-382"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681181191"><span class="annot"><span class="annottext">[SptEntry]
</span><a href="#local-6989586621681181191"><span class="hs-identifier hs-var">spt_entries</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681181190"><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621681181190"><span class="hs-identifier hs-var">tidy_binds'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span>
</span><span id="line-383"></span><span>             </span><span class="annot"><span class="annottext">HscEnv -&gt; Module -&gt; CoreProgram -&gt; IO ([SptEntry], CoreProgram)
</span><a href="GHC.Iface.Tidy.StaticPtrTable.html#sptCreateStaticBinds"><span class="hs-identifier hs-var">sptCreateStaticBinds</span></a></span><span> </span><span class="annot"><span class="annottext">HscEnv
</span><a href="#local-6989586621681181246"><span class="hs-identifier hs-var">hsc_env</span></a></span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681181243"><span class="hs-identifier hs-var">mod</span></a></span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621681181193"><span class="hs-identifier hs-var">tidy_binds</span></a></span><span>
</span><span id="line-384"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681181188"><span class="annot"><span class="annottext">spt_init_code :: SDoc
</span><a href="#local-6989586621681181188"><span class="hs-identifier hs-var hs-var">spt_init_code</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Module -&gt; [SptEntry] -&gt; SDoc
</span><a href="GHC.Iface.Tidy.StaticPtrTable.html#sptModuleInitCode"><span class="hs-identifier hs-var">sptModuleInitCode</span></a></span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681181243"><span class="hs-identifier hs-var">mod</span></a></span><span> </span><span class="annot"><span class="annottext">[SptEntry]
</span><a href="#local-6989586621681181191"><span class="hs-identifier hs-var">spt_entries</span></a></span><span>
</span><span id="line-385"></span><span>              </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681181186"><span class="annot"><span class="annottext">add_spt_init_code :: ForeignStubs -&gt; ForeignStubs
</span><a href="#local-6989586621681181186"><span class="hs-identifier hs-var hs-var">add_spt_init_code</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-386"></span><span>                  </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; HscTarget
</span><a href="GHC.Driver.Session.html#hscTarget"><span class="hs-identifier hs-var hs-var">hscTarget</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681181212"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-387"></span><span>                    </span><span class="hs-comment">-- If we are compiling for the interpreter we will insert</span><span>
</span><span id="line-388"></span><span>                    </span><span class="hs-comment">-- any necessary SPT entries dynamically</span><span>
</span><span id="line-389"></span><span>                    </span><span class="annot"><span class="annottext">HscTarget
</span><a href="GHC.Driver.Session.html#HscInterpreted"><span class="hs-identifier hs-var">HscInterpreted</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">ForeignStubs -&gt; ForeignStubs
forall a. a -&gt; a
</span><a href="../../base/src/GHC.Base.html#id"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-390"></span><span>                    </span><span class="hs-comment">-- otherwise add a C stub to do so</span><span>
</span><span id="line-391"></span><span>                    </span><span class="annot"><span class="annottext">HscTarget
</span><span class="hs-identifier">_</span></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ForeignStubs -&gt; SDoc -&gt; ForeignStubs
</span><a href="GHC.Driver.Types.html#appendStubC"><span class="hs-operator hs-var">`appendStubC`</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681181188"><span class="hs-identifier hs-var">spt_init_code</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-392"></span><span>
</span><span id="line-393"></span><span>              </span><span class="hs-comment">-- The completed type environment is gotten from</span><span>
</span><span id="line-394"></span><span>              </span><span class="hs-comment">--      a) the types and classes defined here (plus implicit things)</span><span>
</span><span id="line-395"></span><span>              </span><span class="hs-comment">--      b) adding Ids with correct IdInfo, including unfoldings,</span><span>
</span><span id="line-396"></span><span>              </span><span class="hs-comment">--              gotten from the bindings</span><span>
</span><span id="line-397"></span><span>              </span><span class="hs-comment">-- From (b) we keep only those Ids with External names;</span><span>
</span><span id="line-398"></span><span>              </span><span class="hs-comment">--          the CoreTidy pass makes sure these are all and only</span><span>
</span><span id="line-399"></span><span>              </span><span class="hs-comment">--          the externally-accessible ones</span><span>
</span><span id="line-400"></span><span>              </span><span class="hs-comment">-- This truncates the type environment to include only the</span><span>
</span><span id="line-401"></span><span>              </span><span class="hs-comment">-- exported Ids and things needed from them, which saves space</span><span>
</span><span id="line-402"></span><span>              </span><span class="hs-comment">--</span><span>
</span><span id="line-403"></span><span>              </span><span class="hs-comment">-- See Note [Don't attempt to trim data types]</span><span>
</span><span id="line-404"></span><span>              </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681181179"><span class="annot"><span class="annottext">final_ids :: [Id]
</span><a href="#local-6989586621681181179"><span class="hs-identifier hs-var hs-var">final_ids</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Id -&gt; Id
</span><a href="GHC.Iface.Tidy.html#trimId"><span class="hs-identifier hs-var">trimId</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681181211"><span class="hs-identifier hs-var">omit_prags</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181177"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-405"></span><span>                             </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621681181177"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181177"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CoreProgram -&gt; [Id]
forall b. [Bind b] -&gt; [b]
</span><a href="GHC.Core.html#bindersOfBinds"><span class="hs-identifier hs-var">bindersOfBinds</span></a></span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621681181193"><span class="hs-identifier hs-var">tidy_binds</span></a></span><span>
</span><span id="line-406"></span><span>                             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Name -&gt; Bool
</span><a href="GHC.Types.Name.html#isExternalName"><span class="hs-identifier hs-var">isExternalName</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Name
</span><a href="GHC.Types.Id.html#idName"><span class="hs-identifier hs-var">idName</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181177"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-407"></span><span>                             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Bool
forall thing. NamedThing thing =&gt; thing -&gt; Bool
</span><a href="GHC.Types.Name.html#isWiredIn"><span class="hs-identifier hs-var">isWiredIn</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181177"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-408"></span><span>                             </span><span class="hs-special">]</span><span>   </span><span class="hs-comment">-- See Note [Drop wired-in things]</span><span>
</span><span id="line-409"></span><span>
</span><span id="line-410"></span><span>              </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681181172"><span class="annot"><span class="annottext">final_tcs :: [TyCon]
</span><a href="#local-6989586621681181172"><span class="hs-identifier hs-var hs-var">final_tcs</span></a></span></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TyCon -&gt; Bool) -&gt; [TyCon] -&gt; [TyCon]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="GHC.Utils.Misc.html#filterOut"><span class="hs-identifier hs-var">filterOut</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Bool
forall thing. NamedThing thing =&gt; thing -&gt; Bool
</span><a href="GHC.Types.Name.html#isWiredIn"><span class="hs-identifier hs-var">isWiredIn</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCon]
</span><a href="#local-6989586621681181237"><span class="hs-identifier hs-var">tcs</span></a></span><span>
</span><span id="line-411"></span><span>                                 </span><span class="hs-comment">-- See Note [Drop wired-in things]</span><span>
</span><span id="line-412"></span><span>              </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681181171"><span class="annot"><span class="annottext">type_env :: TypeEnv
</span><a href="#local-6989586621681181171"><span class="hs-identifier hs-var hs-var">type_env</span></a></span></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; [TyCon] -&gt; [FamInst] -&gt; TypeEnv
</span><a href="GHC.Driver.Types.html#typeEnvFromEntities"><span class="hs-identifier hs-var">typeEnvFromEntities</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681181179"><span class="hs-identifier hs-var">final_ids</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCon]
</span><a href="#local-6989586621681181172"><span class="hs-identifier hs-var">final_tcs</span></a></span><span> </span><span class="annot"><span class="annottext">[FamInst]
</span><a href="#local-6989586621681181233"><span class="hs-identifier hs-var">fam_insts</span></a></span><span>
</span><span id="line-413"></span><span>              </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681181170"><span class="annot"><span class="annottext">tidy_cls_insts :: [ClsInst]
</span><a href="#local-6989586621681181170"><span class="hs-identifier hs-var hs-var">tidy_cls_insts</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TypeEnv -&gt; [ClsInst] -&gt; [ClsInst]
</span><a href="GHC.Iface.Tidy.html#mkFinalClsInsts"><span class="hs-identifier hs-var">mkFinalClsInsts</span></a></span><span> </span><span class="annot"><span class="annottext">TypeEnv
</span><a href="#local-6989586621681181171"><span class="hs-identifier hs-var">type_env</span></a></span><span> </span><span class="annot"><span class="annottext">[ClsInst]
</span><a href="#local-6989586621681181235"><span class="hs-identifier hs-var">cls_insts</span></a></span><span>
</span><span id="line-414"></span><span>              </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681181169"><span class="annot"><span class="annottext">tidy_patsyns :: [PatSyn]
</span><a href="#local-6989586621681181169"><span class="hs-identifier hs-var hs-var">tidy_patsyns</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TypeEnv -&gt; [PatSyn] -&gt; [PatSyn]
</span><a href="GHC.Iface.Tidy.html#mkFinalPatSyns"><span class="hs-identifier hs-var">mkFinalPatSyns</span></a></span><span>  </span><span class="annot"><span class="annottext">TypeEnv
</span><a href="#local-6989586621681181171"><span class="hs-identifier hs-var">type_env</span></a></span><span> </span><span class="annot"><span class="annottext">[PatSyn]
</span><a href="#local-6989586621681181229"><span class="hs-identifier hs-var">patsyns</span></a></span><span>
</span><span id="line-415"></span><span>              </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681181168"><span class="annot"><span class="annottext">tidy_type_env :: TypeEnv
</span><a href="#local-6989586621681181168"><span class="hs-identifier hs-var hs-var">tidy_type_env</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[PatSyn] -&gt; TypeEnv -&gt; TypeEnv
</span><a href="GHC.Iface.Tidy.html#extendTypeEnvWithPatSyns"><span class="hs-identifier hs-var">extendTypeEnvWithPatSyns</span></a></span><span> </span><span class="annot"><span class="annottext">[PatSyn]
</span><a href="#local-6989586621681181169"><span class="hs-identifier hs-var">tidy_patsyns</span></a></span><span> </span><span class="annot"><span class="annottext">TypeEnv
</span><a href="#local-6989586621681181171"><span class="hs-identifier hs-var">type_env</span></a></span><span>
</span><span id="line-416"></span><span>              </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681181167"><span class="annot"><span class="annottext">tidy_rules :: [CoreRule]
</span><a href="#local-6989586621681181167"><span class="hs-identifier hs-var hs-var">tidy_rules</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; [CoreRule] -&gt; [CoreRule]
</span><a href="GHC.Core.Tidy.html#tidyRules"><span class="hs-identifier hs-var">tidyRules</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681181194"><span class="hs-identifier hs-var">tidy_env</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621681181196"><span class="hs-identifier hs-var">trimmed_rules</span></a></span><span>
</span><span id="line-417"></span><span>
</span><span id="line-418"></span><span>              </span><span class="hs-special">;</span><span> </span><span class="hs-comment">-- See Note [Injecting implicit bindings]</span><span>
</span><span id="line-419"></span><span>                </span><span id="local-6989586621681181165"><span class="annot"><span class="annottext">all_tidy_binds :: CoreProgram
</span><a href="#local-6989586621681181165"><span class="hs-identifier hs-var hs-var">all_tidy_binds</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621681181203"><span class="hs-identifier hs-var">implicit_binds</span></a></span><span> </span><span class="annot"><span class="annottext">CoreProgram -&gt; CoreProgram -&gt; CoreProgram
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621681181190"><span class="hs-identifier hs-var">tidy_binds'</span></a></span><span>
</span><span id="line-420"></span><span>
</span><span id="line-421"></span><span>              </span><span class="hs-comment">-- Get the TyCons to generate code for.  Careful!  We must use</span><span>
</span><span id="line-422"></span><span>              </span><span class="hs-comment">-- the untidied TyCons here, because we need</span><span>
</span><span id="line-423"></span><span>              </span><span class="hs-comment">--  (a) implicit TyCons arising from types and classes defined</span><span>
</span><span id="line-424"></span><span>              </span><span class="hs-comment">--      in this module</span><span>
</span><span id="line-425"></span><span>              </span><span class="hs-comment">--  (b) wired-in TyCons, which are normally removed from the</span><span>
</span><span id="line-426"></span><span>              </span><span class="hs-comment">--      TypeEnv we put in the ModDetails</span><span>
</span><span id="line-427"></span><span>              </span><span class="hs-comment">--  (c) Constructors even if they are not exported (the</span><span>
</span><span id="line-428"></span><span>              </span><span class="hs-comment">--      tidied TypeEnv has trimmed these away)</span><span>
</span><span id="line-429"></span><span>              </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681181164"><span class="annot"><span class="annottext">alg_tycons :: [TyCon]
</span><a href="#local-6989586621681181164"><span class="hs-identifier hs-var hs-var">alg_tycons</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TyCon -&gt; Bool) -&gt; [TyCon] -&gt; [TyCon]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isAlgTyCon"><span class="hs-identifier hs-var">isAlgTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCon]
</span><a href="#local-6989586621681181237"><span class="hs-identifier hs-var">tcs</span></a></span><span>
</span><span id="line-430"></span><span>              </span><span class="hs-special">}</span><span>
</span><span id="line-431"></span><span>
</span><span id="line-432"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">HscEnv
-&gt; PrintUnqualified
-&gt; CoreToDo
-&gt; CoreProgram
-&gt; [CoreRule]
-&gt; IO ()
</span><a href="GHC.Core.Lint.html#endPassIO"><span class="hs-identifier hs-var">endPassIO</span></a></span><span> </span><span class="annot"><span class="annottext">HscEnv
</span><a href="#local-6989586621681181246"><span class="hs-identifier hs-var">hsc_env</span></a></span><span> </span><span class="annot"><span class="annottext">PrintUnqualified
</span><a href="#local-6989586621681181206"><span class="hs-identifier hs-var">print_unqual</span></a></span><span> </span><span class="annot"><span class="annottext">CoreToDo
</span><a href="GHC.Core.Opt.Monad.html#CoreTidy"><span class="hs-identifier hs-var">CoreTidy</span></a></span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621681181165"><span class="hs-identifier hs-var">all_tidy_binds</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621681181167"><span class="hs-identifier hs-var">tidy_rules</span></a></span><span>
</span><span id="line-433"></span><span>
</span><span id="line-434"></span><span>          </span><span class="hs-comment">-- If the endPass didn't print the rules, but ddump-rules is</span><span>
</span><span id="line-435"></span><span>          </span><span class="hs-comment">-- on, print now</span><span>
</span><span id="line-436"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; IO () -&gt; IO ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/Control.Monad.html#unless"><span class="hs-identifier hs-var">unless</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DumpFlag -&gt; DynFlags -&gt; Bool
</span><a href="GHC.Driver.Session.html#dopt"><span class="hs-identifier hs-var">dopt</span></a></span><span> </span><span class="annot"><span class="annottext">DumpFlag
</span><a href="GHC.Driver.Flags.html#Opt_D_dump_simpl"><span class="hs-identifier hs-var">Opt_D_dump_simpl</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681181212"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IO () -&gt; IO ()) -&gt; IO () -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-437"></span><span>            </span><span class="annot"><span class="annottext">DynFlags -&gt; DumpFlag -&gt; String -&gt; DumpFormat -&gt; SDoc -&gt; IO ()
</span><a href="GHC.Utils.Error.html#dumpIfSet_dyn"><span class="hs-identifier hs-var">Err.dumpIfSet_dyn</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681181212"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">DumpFlag
</span><a href="GHC.Driver.Flags.html#Opt_D_dump_rules"><span class="hs-identifier hs-var">Opt_D_dump_rules</span></a></span><span>
</span><span id="line-438"></span><span>              </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; SDoc -&gt; String
</span><a href="GHC.Utils.Outputable.html#showSDoc"><span class="hs-identifier hs-var">showSDoc</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681181212"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreToDo -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">CoreToDo
</span><a href="GHC.Core.Opt.Monad.html#CoreTidy"><span class="hs-identifier hs-var">CoreTidy</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;rules&quot;</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-439"></span><span>              </span><span class="annot"><span class="annottext">DumpFormat
</span><a href="GHC.Utils.Error.html#FormatText"><span class="hs-identifier hs-var">Err.FormatText</span></a></span><span>
</span><span id="line-440"></span><span>              </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[CoreRule] -&gt; SDoc
</span><a href="GHC.Core.Rules.html#pprRulesForUser"><span class="hs-identifier hs-var">pprRulesForUser</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621681181167"><span class="hs-identifier hs-var">tidy_rules</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-441"></span><span>
</span><span id="line-442"></span><span>          </span><span class="hs-comment">-- Print one-line size info</span><span>
</span><span id="line-443"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681181152"><span class="annot"><span class="annottext">cs :: CoreStats
</span><a href="#local-6989586621681181152"><span class="hs-identifier hs-var hs-var">cs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreProgram -&gt; CoreStats
</span><a href="GHC.Core.Stats.html#coreBindsStats"><span class="hs-identifier hs-var">coreBindsStats</span></a></span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621681181193"><span class="hs-identifier hs-var">tidy_binds</span></a></span><span>
</span><span id="line-444"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; DumpFlag -&gt; String -&gt; DumpFormat -&gt; SDoc -&gt; IO ()
</span><a href="GHC.Utils.Error.html#dumpIfSet_dyn"><span class="hs-identifier hs-var">Err.dumpIfSet_dyn</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681181212"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">DumpFlag
</span><a href="GHC.Driver.Flags.html#Opt_D_dump_core_stats"><span class="hs-identifier hs-var">Opt_D_dump_core_stats</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Core Stats&quot;</span></span><span>
</span><span id="line-445"></span><span>            </span><span class="annot"><span class="annottext">DumpFormat
</span><a href="GHC.Utils.Error.html#FormatText"><span class="hs-identifier hs-var">Err.FormatText</span></a></span><span>
</span><span id="line-446"></span><span>            </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Tidy size (terms,types,coercions)&quot;</span></span><span>
</span><span id="line-447"></span><span>             </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">ModuleName -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Module -&gt; ModuleName
forall unit. GenModule unit -&gt; ModuleName
</span><a href="GHC.Unit.Types.html#moduleName"><span class="hs-identifier hs-var hs-var">moduleName</span></a></span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681181243"><span class="hs-identifier hs-var">mod</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#colon"><span class="hs-identifier hs-var">colon</span></a></span><span>
</span><span id="line-448"></span><span>             </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#int"><span class="hs-identifier hs-var">int</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreStats -&gt; Int
</span><a href="GHC.Core.Stats.html#cs_tm"><span class="hs-identifier hs-var hs-var">cs_tm</span></a></span><span> </span><span class="annot"><span class="annottext">CoreStats
</span><a href="#local-6989586621681181152"><span class="hs-identifier hs-var">cs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-449"></span><span>             </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#int"><span class="hs-identifier hs-var">int</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreStats -&gt; Int
</span><a href="GHC.Core.Stats.html#cs_ty"><span class="hs-identifier hs-var hs-var">cs_ty</span></a></span><span> </span><span class="annot"><span class="annottext">CoreStats
</span><a href="#local-6989586621681181152"><span class="hs-identifier hs-var">cs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-450"></span><span>             </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#int"><span class="hs-identifier hs-var">int</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreStats -&gt; Int
</span><a href="GHC.Core.Stats.html#cs_co"><span class="hs-identifier hs-var hs-var">cs_co</span></a></span><span> </span><span class="annot"><span class="annottext">CoreStats
</span><a href="#local-6989586621681181152"><span class="hs-identifier hs-var">cs</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-451"></span><span>
</span><span id="line-452"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(CgGuts, ModDetails) -&gt; IO (CgGuts, ModDetails)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CgGuts :: Module
-&gt; [TyCon]
-&gt; CoreProgram
-&gt; ForeignStubs
-&gt; [(ForeignSrcLang, String)]
-&gt; [UnitId]
-&gt; HpcInfo
-&gt; Maybe ModBreaks
-&gt; [SptEntry]
-&gt; CgGuts
</span><a href="GHC.Driver.Types.html#CgGuts"><span class="hs-identifier hs-type">CgGuts</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">cg_module :: Module
</span><a href="GHC.Driver.Types.html#cg_module"><span class="hs-identifier hs-var">cg_module</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681181243"><span class="hs-identifier hs-var">mod</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-453"></span><span>                           </span><span class="annot"><span class="annottext">cg_tycons :: [TyCon]
</span><a href="GHC.Driver.Types.html#cg_tycons"><span class="hs-identifier hs-var">cg_tycons</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TyCon]
</span><a href="#local-6989586621681181164"><span class="hs-identifier hs-var">alg_tycons</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-454"></span><span>                           </span><span class="annot"><span class="annottext">cg_binds :: CoreProgram
</span><a href="GHC.Driver.Types.html#cg_binds"><span class="hs-identifier hs-var">cg_binds</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621681181165"><span class="hs-identifier hs-var">all_tidy_binds</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-455"></span><span>                           </span><span class="annot"><span class="annottext">cg_foreign :: ForeignStubs
</span><a href="GHC.Driver.Types.html#cg_foreign"><span class="hs-identifier hs-var">cg_foreign</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ForeignStubs -&gt; ForeignStubs
</span><a href="#local-6989586621681181186"><span class="hs-identifier hs-var">add_spt_init_code</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignStubs
</span><a href="#local-6989586621681181219"><span class="hs-identifier hs-var">foreign_stubs</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-456"></span><span>                           </span><span class="annot"><span class="annottext">cg_foreign_files :: [(ForeignSrcLang, String)]
</span><a href="GHC.Driver.Types.html#cg_foreign_files"><span class="hs-identifier hs-var">cg_foreign_files</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(ForeignSrcLang, String)]
</span><a href="#local-6989586621681181217"><span class="hs-identifier hs-var">foreign_files</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-457"></span><span>                           </span><span class="annot"><span class="annottext">cg_dep_pkgs :: [UnitId]
</span><a href="GHC.Driver.Types.html#cg_dep_pkgs"><span class="hs-identifier hs-var">cg_dep_pkgs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((UnitId, Bool) -&gt; UnitId) -&gt; [(UnitId, Bool)] -&gt; [UnitId]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">(UnitId, Bool) -&gt; UnitId
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span> </span><span class="annot"><span class="annottext">([(UnitId, Bool)] -&gt; [UnitId]) -&gt; [(UnitId, Bool)] -&gt; [UnitId]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Dependencies -&gt; [(UnitId, Bool)]
</span><a href="GHC.Driver.Types.html#dep_pkgs"><span class="hs-identifier hs-var hs-var">dep_pkgs</span></a></span><span> </span><span class="annot"><span class="annottext">Dependencies
</span><a href="#local-6989586621681181221"><span class="hs-identifier hs-var">deps</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-458"></span><span>                           </span><span class="annot"><span class="annottext">cg_hpc_info :: HpcInfo
</span><a href="GHC.Driver.Types.html#cg_hpc_info"><span class="hs-identifier hs-var">cg_hpc_info</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HpcInfo
</span><a href="#local-6989586621681181215"><span class="hs-identifier hs-var">hpc_info</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-459"></span><span>                           </span><span class="annot"><span class="annottext">cg_modBreaks :: Maybe ModBreaks
</span><a href="GHC.Driver.Types.html#cg_modBreaks"><span class="hs-identifier hs-var">cg_modBreaks</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe ModBreaks
</span><a href="#local-6989586621681181213"><span class="hs-identifier hs-var">modBreaks</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-460"></span><span>                           </span><span class="annot"><span class="annottext">cg_spt_entries :: [SptEntry]
</span><a href="GHC.Driver.Types.html#cg_spt_entries"><span class="hs-identifier hs-var">cg_spt_entries</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[SptEntry]
</span><a href="#local-6989586621681181191"><span class="hs-identifier hs-var">spt_entries</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">,</span><span>
</span><span id="line-461"></span><span>
</span><span id="line-462"></span><span>                   </span><span class="annot"><span class="annottext">ModDetails :: [AvailInfo]
-&gt; TypeEnv
-&gt; [ClsInst]
-&gt; [FamInst]
-&gt; [CoreRule]
-&gt; [Annotation]
-&gt; [CompleteMatch]
-&gt; ModDetails
</span><a href="GHC.Driver.Types.html#ModDetails"><span class="hs-identifier hs-type">ModDetails</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">md_types :: TypeEnv
</span><a href="GHC.Driver.Types.html#md_types"><span class="hs-identifier hs-var">md_types</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TypeEnv
</span><a href="#local-6989586621681181168"><span class="hs-identifier hs-var">tidy_type_env</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-463"></span><span>                                </span><span class="annot"><span class="annottext">md_rules :: [CoreRule]
</span><a href="GHC.Driver.Types.html#md_rules"><span class="hs-identifier hs-var">md_rules</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621681181167"><span class="hs-identifier hs-var">tidy_rules</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-464"></span><span>                                </span><span class="annot"><span class="annottext">md_insts :: [ClsInst]
</span><a href="GHC.Driver.Types.html#md_insts"><span class="hs-identifier hs-var">md_insts</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[ClsInst]
</span><a href="#local-6989586621681181170"><span class="hs-identifier hs-var">tidy_cls_insts</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-465"></span><span>                                </span><span class="annot"><span class="annottext">md_fam_insts :: [FamInst]
</span><a href="GHC.Driver.Types.html#md_fam_insts"><span class="hs-identifier hs-var">md_fam_insts</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[FamInst]
</span><a href="#local-6989586621681181233"><span class="hs-identifier hs-var">fam_insts</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-466"></span><span>                                </span><span class="annot"><span class="annottext">md_exports :: [AvailInfo]
</span><a href="GHC.Driver.Types.html#md_exports"><span class="hs-identifier hs-var">md_exports</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[AvailInfo]
</span><a href="#local-6989586621681181241"><span class="hs-identifier hs-var">exports</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-467"></span><span>                                </span><span class="annot"><span class="annottext">md_anns :: [Annotation]
</span><a href="GHC.Driver.Types.html#md_anns"><span class="hs-identifier hs-var">md_anns</span></a></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Annotation]
</span><a href="#local-6989586621681181225"><span class="hs-identifier hs-var">anns</span></a></span><span class="hs-special">,</span><span>      </span><span class="hs-comment">-- are already tidy</span><span>
</span><span id="line-468"></span><span>                                </span><span class="annot"><span class="annottext">md_complete_sigs :: [CompleteMatch]
</span><a href="GHC.Driver.Types.html#md_complete_sigs"><span class="hs-identifier hs-var">md_complete_sigs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[CompleteMatch]
</span><a href="#local-6989586621681181223"><span class="hs-identifier hs-var">complete_sigs</span></a></span><span>
</span><span id="line-469"></span><span>                              </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-470"></span><span>        </span><span class="hs-special">}</span><span>
</span><span id="line-471"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-472"></span><span>    </span><span id="local-6989586621681181212"><span class="annot"><span class="annottext">dflags :: DynFlags
</span><a href="#local-6989586621681181212"><span class="hs-identifier hs-var hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HscEnv -&gt; DynFlags
</span><a href="GHC.Driver.Types.html#hsc_dflags"><span class="hs-identifier hs-var hs-var">hsc_dflags</span></a></span><span> </span><span class="annot"><span class="annottext">HscEnv
</span><a href="#local-6989586621681181246"><span class="hs-identifier hs-var">hsc_env</span></a></span><span>
</span><span id="line-473"></span><span>
</span><span id="line-474"></span><span class="hs-comment">--------------------------</span><span>
</span><span id="line-475"></span><span class="annot"><a href="GHC.Iface.Tidy.html#trimId"><span class="hs-identifier hs-type">trimId</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span>
</span><span id="line-476"></span><span class="hs-comment">-- With -O0 we now trim off the arity, one-shot-ness, strictness</span><span>
</span><span id="line-477"></span><span class="hs-comment">-- etc which tidyTopIdInfo retains for the benefit of the code generator</span><span>
</span><span id="line-478"></span><span class="hs-comment">-- but which we don't want in the interface file or ModIface for</span><span>
</span><span id="line-479"></span><span class="hs-comment">-- downstream compilations</span><span>
</span><span id="line-480"></span><span id="trimId"><span class="annot"><span class="annottext">trimId :: Bool -&gt; Id -&gt; Id
</span><a href="GHC.Iface.Tidy.html#trimId"><span class="hs-identifier hs-var hs-var">trimId</span></a></span></span><span> </span><span id="local-6989586621681181132"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681181132"><span class="hs-identifier hs-var">omit_prags</span></a></span></span><span> </span><span id="local-6989586621681181131"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181131"><span class="hs-identifier hs-var">id</span></a></span></span><span>
</span><span id="line-481"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681181132"><span class="hs-identifier hs-var">omit_prags</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Id.html#isImplicitId"><span class="hs-identifier hs-var">isImplicitId</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181131"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-482"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181131"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; IdInfo -&gt; Id
</span><a href="GHC.Types.Id.html#setIdInfo"><span class="hs-operator hs-var">`setIdInfo`</span></a></span><span>      </span><span class="annot"><span class="annottext">IdInfo
</span><a href="GHC.Types.Id.Info.html#vanillaIdInfo"><span class="hs-identifier hs-var">vanillaIdInfo</span></a></span><span>
</span><span id="line-483"></span><span>       </span><span class="annot"><span class="annottext">Id -&gt; Unfolding -&gt; Id
</span><a href="GHC.Types.Id.html#setIdUnfolding"><span class="hs-operator hs-var">`setIdUnfolding`</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Unfolding
</span><a href="GHC.Types.Id.html#idUnfolding"><span class="hs-identifier hs-var">idUnfolding</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181131"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-484"></span><span>       </span><span class="hs-comment">-- We respect the final unfolding chosen by tidyTopIdInfo.</span><span>
</span><span id="line-485"></span><span>       </span><span class="hs-comment">-- We have already trimmed it if we don't want it for -O0;</span><span>
</span><span id="line-486"></span><span>       </span><span class="hs-comment">-- see also Note [Always expose compulsory unfoldings]</span><span>
</span><span id="line-487"></span><span>
</span><span id="line-488"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>   </span><span class="hs-comment">-- No trimming</span><span>
</span><span id="line-489"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181131"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-490"></span><span>
</span><span id="line-491"></span><span class="hs-comment">{- Note [Drop wired-in things]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We never put wired-in TyCons or Ids in an interface file.
They are wired-in, so the compiler knows about them already.

Note [Don't attempt to trim data types]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
For some time GHC tried to avoid exporting the data constructors
of a data type if it wasn't strictly necessary to do so; see #835.
But &quot;strictly necessary&quot; accumulated a longer and longer list
of exceptions, and finally I gave up the battle:

    commit 9a20e540754fc2af74c2e7392f2786a81d8d5f11
    Author: Simon Peyton Jones &lt;simonpj@microsoft.com&gt;
    Date:   Thu Dec 6 16:03:16 2012 +0000

    Stop attempting to &quot;trim&quot; data types in interface files

    Without -O, we previously tried to make interface files smaller
    by not including the data constructors of data types.  But
    there are a lot of exceptions, notably when Template Haskell is
    involved or, more recently, DataKinds.

    However #7445 shows that even without TemplateHaskell, using
    the Data class and invoking Language.Haskell.TH.Quote.dataToExpQ
    is enough to require us to expose the data constructors.

    So I've given up on this &quot;optimisation&quot; -- it's probably not
    important anyway.  Now I'm simply not attempting to trim off
    the data constructors.  The gain in simplicity is worth the
    modest cost in interface file growth, which is limited to the
    bits reqd to describe those data constructors.

************************************************************************
*                                                                      *
        Implicit bindings
*                                                                      *
************************************************************************

Note [Injecting implicit bindings]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We inject the implicit bindings right at the end, in GHC.Core.Tidy.
Some of these bindings, notably record selectors, are not
constructed in an optimised form.  E.g. record selector for
        data T = MkT { x :: {-# UNPACK #-} !Int }
Then the unfolding looks like
        x = \t. case t of MkT x1 -&gt; let x = I# x1 in x
This generates bad code unless it's first simplified a bit.  That is
why GHC.Core.Unfold.mkImplicitUnfolding uses simpleOptExpr to do a bit of
optimisation first.  (Only matters when the selector is used curried;
eg map x ys.)  See #2070.

[Oct 09: in fact, record selectors are no longer implicit Ids at all,
because we really do want to optimise them properly. They are treated
much like any other Id.  But doing &quot;light&quot; optimisation on an implicit
Id still makes sense.]

At one time I tried injecting the implicit bindings *early*, at the
beginning of SimplCore.  But that gave rise to real difficulty,
because GlobalIds are supposed to have *fixed* IdInfo, but the
simplifier and other core-to-core passes mess with IdInfo all the
time.  The straw that broke the camels back was when a class selector
got the wrong arity -- ie the simplifier gave it arity 2, whereas
importing modules were expecting it to have arity 1 (#2844).
It's much safer just to inject them right at the end, after tidying.

Oh: two other reasons for injecting them late:

  - If implicit Ids are already in the bindings when we start tidying,
    we'd have to be careful not to treat them as external Ids (in
    the sense of chooseExternalIds); else the Ids mentioned in *their*
    RHSs will be treated as external and you get an interface file
    saying      a18 = &lt;blah&gt;
    but nothing referring to a18 (because the implicit Id is the
    one that does, and implicit Ids don't appear in interface files).

  - More seriously, the tidied type-envt will include the implicit
    Id replete with a18 in its unfolding; but we won't take account
    of a18 when computing a fingerprint for the class; result chaos.

There is one sort of implicit binding that is injected still later,
namely those for data constructor workers. Reason (I think): it's
really just a code generation trick.... binding itself makes no sense.
See Note [Data constructor workers] in &quot;GHC.CoreToStg.Prep&quot;.
-}</span><span>
</span><span id="line-576"></span><span>
</span><span id="line-577"></span><span class="annot"><a href="GHC.Iface.Tidy.html#getImplicitBinds"><span class="hs-identifier hs-type">getImplicitBinds</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreBind"><span class="hs-identifier hs-type">CoreBind</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-578"></span><span id="getImplicitBinds"><span class="annot"><span class="annottext">getImplicitBinds :: TyCon -&gt; CoreProgram
</span><a href="GHC.Iface.Tidy.html#getImplicitBinds"><span class="hs-identifier hs-var hs-var">getImplicitBinds</span></a></span></span><span> </span><span id="local-6989586621681181126"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681181126"><span class="hs-identifier hs-var">tc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621681181125"><span class="hs-identifier hs-var">cls_binds</span></a></span><span> </span><span class="annot"><span class="annottext">CoreProgram -&gt; CoreProgram -&gt; CoreProgram
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; CoreProgram
</span><a href="GHC.Iface.Tidy.html#getTyConImplicitBinds"><span class="hs-identifier hs-var">getTyConImplicitBinds</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681181126"><span class="hs-identifier hs-var">tc</span></a></span><span>
</span><span id="line-579"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-580"></span><span>    </span><span id="local-6989586621681181125"><span class="annot"><span class="annottext">cls_binds :: CoreProgram
</span><a href="#local-6989586621681181125"><span class="hs-identifier hs-var hs-var">cls_binds</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreProgram -&gt; (Class -&gt; CoreProgram) -&gt; Maybe Class -&gt; CoreProgram
forall b a. b -&gt; (a -&gt; b) -&gt; Maybe a -&gt; b
</span><a href="../../base/src/Data.Maybe.html#maybe"><span class="hs-identifier hs-var">maybe</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">Class -&gt; CoreProgram
</span><a href="GHC.Iface.Tidy.html#getClassImplicitBinds"><span class="hs-identifier hs-var">getClassImplicitBinds</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; Maybe Class
</span><a href="GHC.Core.TyCon.html#tyConClass_maybe"><span class="hs-identifier hs-var">tyConClass_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681181126"><span class="hs-identifier hs-var">tc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-581"></span><span>
</span><span id="line-582"></span><span class="annot"><a href="GHC.Iface.Tidy.html#getTyConImplicitBinds"><span class="hs-identifier hs-type">getTyConImplicitBinds</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreBind"><span class="hs-identifier hs-type">CoreBind</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-583"></span><span id="getTyConImplicitBinds"><span class="annot"><span class="annottext">getTyConImplicitBinds :: TyCon -&gt; CoreProgram
</span><a href="GHC.Iface.Tidy.html#getTyConImplicitBinds"><span class="hs-identifier hs-var hs-var">getTyConImplicitBinds</span></a></span></span><span> </span><span id="local-6989586621681181120"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681181120"><span class="hs-identifier hs-var">tc</span></a></span></span><span>
</span><span id="line-584"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isNewTyCon"><span class="hs-identifier hs-var">isNewTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681181120"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>  </span><span class="hs-comment">-- See Note [Compulsory newtype unfolding] in GHC.Types.Id.Make</span><span>
</span><span id="line-585"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Id -&gt; CoreBind) -&gt; [Id] -&gt; CoreProgram
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; CoreBind
</span><a href="GHC.Iface.Tidy.html#get_defn"><span class="hs-identifier hs-var">get_defn</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(DataCon -&gt; Maybe Id) -&gt; [DataCon] -&gt; [Id]
forall a b. (a -&gt; Maybe b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/Data.Maybe.html#mapMaybe"><span class="hs-identifier hs-var">mapMaybe</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon -&gt; Maybe Id
</span><a href="GHC.Core.DataCon.html#dataConWrapId_maybe"><span class="hs-identifier hs-var">dataConWrapId_maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; [DataCon]
</span><a href="GHC.Core.TyCon.html#tyConDataCons"><span class="hs-identifier hs-var">tyConDataCons</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681181120"><span class="hs-identifier hs-var">tc</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-586"></span><span>
</span><span id="line-587"></span><span class="annot"><a href="GHC.Iface.Tidy.html#getClassImplicitBinds"><span class="hs-identifier hs-type">getClassImplicitBinds</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Class.html#Class"><span class="hs-identifier hs-type">Class</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreBind"><span class="hs-identifier hs-type">CoreBind</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-588"></span><span id="getClassImplicitBinds"><span class="annot"><span class="annottext">getClassImplicitBinds :: Class -&gt; CoreProgram
</span><a href="GHC.Iface.Tidy.html#getClassImplicitBinds"><span class="hs-identifier hs-var hs-var">getClassImplicitBinds</span></a></span></span><span> </span><span id="local-6989586621681181114"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681181114"><span class="hs-identifier hs-var">cls</span></a></span></span><span>
</span><span id="line-589"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Expr Id -&gt; CoreBind
forall b. b -&gt; Expr b -&gt; Bind b
</span><a href="GHC.Core.html#NonRec"><span class="hs-identifier hs-var">NonRec</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181112"><span class="hs-identifier hs-var">op</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Class -&gt; Int -&gt; Expr Id
</span><a href="GHC.Types.Id.Make.html#mkDictSelRhs"><span class="hs-identifier hs-var">mkDictSelRhs</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681181114"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681181111"><span class="hs-identifier hs-var">val_index</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-590"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681181112"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181112"><span class="hs-identifier hs-var">op</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681181111"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681181111"><span class="hs-identifier hs-var">val_index</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Class -&gt; [Id]
</span><a href="GHC.Core.Class.html#classAllSelIds"><span class="hs-identifier hs-var">classAllSelIds</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681181114"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; [Int] -&gt; [(Id, Int)]
forall a b. [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="../../base/src/GHC.List.html#zip"><span class="hs-operator hs-var">`zip`</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-glyph">..</span><span class="hs-special">]</span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-591"></span><span>
</span><span id="line-592"></span><span class="annot"><a href="GHC.Iface.Tidy.html#get_defn"><span class="hs-identifier hs-type">get_defn</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreBind"><span class="hs-identifier hs-type">CoreBind</span></a></span><span>
</span><span id="line-593"></span><span id="get_defn"><span class="annot"><span class="annottext">get_defn :: Id -&gt; CoreBind
</span><a href="GHC.Iface.Tidy.html#get_defn"><span class="hs-identifier hs-var hs-var">get_defn</span></a></span></span><span> </span><span id="local-6989586621681181109"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181109"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Expr Id -&gt; CoreBind
forall b. b -&gt; Expr b -&gt; Bind b
</span><a href="GHC.Core.html#NonRec"><span class="hs-identifier hs-var">NonRec</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181109"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Unfolding -&gt; Expr Id
</span><a href="GHC.Core.html#unfoldingTemplate"><span class="hs-identifier hs-var">unfoldingTemplate</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Unfolding
</span><a href="GHC.Types.Id.html#realIdUnfolding"><span class="hs-identifier hs-var">realIdUnfolding</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181109"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-594"></span><span>
</span><span id="line-595"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
\subsection{Step 1: finding externals}
*                                                                      *
************************************************************************

See Note [Choosing external Ids].
-}</span><span>
</span><span id="line-604"></span><span>
</span><span id="line-605"></span><span class="hs-keyword">type</span><span> </span><span id="UnfoldEnv"><span class="annot"><a href="GHC.Iface.Tidy.html#UnfoldEnv"><span class="hs-identifier hs-var">UnfoldEnv</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#IdEnv"><span class="hs-identifier hs-type">IdEnv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-comment">{-new name-}</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-comment">{-show unfolding-}</span><span class="hs-special">)</span><span>
</span><span id="line-606"></span><span>  </span><span class="hs-comment">-- Maps each top-level Id to its new Name (the Id is tidied in step 2)</span><span>
</span><span id="line-607"></span><span>  </span><span class="hs-comment">-- The Unique is unchanged.  If the new Name is external, it will be</span><span>
</span><span id="line-608"></span><span>  </span><span class="hs-comment">-- visible in the interface file.</span><span>
</span><span id="line-609"></span><span>  </span><span class="hs-comment">--</span><span>
</span><span id="line-610"></span><span>  </span><span class="hs-comment">-- Bool =&gt; expose unfolding or not.</span><span>
</span><span id="line-611"></span><span>
</span><span id="line-612"></span><span class="annot"><a href="GHC.Iface.Tidy.html#chooseExternalIds"><span class="hs-identifier hs-type">chooseExternalIds</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Types.html#HscEnv"><span class="hs-identifier hs-type">HscEnv</span></a></span><span>
</span><span id="line-613"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Unit.Types.html#Module"><span class="hs-identifier hs-type">Module</span></a></span><span>
</span><span id="line-614"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-615"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreBind"><span class="hs-identifier hs-type">CoreBind</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-616"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreBind"><span class="hs-identifier hs-type">CoreBind</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-617"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreRule"><span class="hs-identifier hs-type">CoreRule</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-618"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Iface.Tidy.html#UnfoldEnv"><span class="hs-identifier hs-type">UnfoldEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Name.Occurrence.html#TidyOccEnv"><span class="hs-identifier hs-type">TidyOccEnv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-619"></span><span>                  </span><span class="hs-comment">-- Step 1 from the notes above</span><span>
</span><span id="line-620"></span><span>
</span><span id="line-621"></span><span id="chooseExternalIds"><span class="annot"><span class="annottext">chooseExternalIds :: HscEnv
-&gt; Module
-&gt; Bool
-&gt; Bool
-&gt; CoreProgram
-&gt; CoreProgram
-&gt; [CoreRule]
-&gt; IO (UnfoldEnv, TidyOccEnv)
</span><a href="GHC.Iface.Tidy.html#chooseExternalIds"><span class="hs-identifier hs-var hs-var">chooseExternalIds</span></a></span></span><span> </span><span id="local-6989586621681181105"><span class="annot"><span class="annottext">HscEnv
</span><a href="#local-6989586621681181105"><span class="hs-identifier hs-var">hsc_env</span></a></span></span><span> </span><span id="local-6989586621681181104"><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681181104"><span class="hs-identifier hs-var">mod</span></a></span></span><span> </span><span id="local-6989586621681181103"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681181103"><span class="hs-identifier hs-var">omit_prags</span></a></span></span><span> </span><span id="local-6989586621681181102"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681181102"><span class="hs-identifier hs-var">expose_all</span></a></span></span><span> </span><span id="local-6989586621681181101"><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621681181101"><span class="hs-identifier hs-var">binds</span></a></span></span><span> </span><span id="local-6989586621681181100"><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621681181100"><span class="hs-identifier hs-var">implicit_binds</span></a></span></span><span> </span><span id="local-6989586621681181099"><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621681181099"><span class="hs-identifier hs-var">imp_id_rules</span></a></span></span><span>
</span><span id="line-622"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681181098"><span class="annot"><span class="annottext">UnfoldEnv
</span><a href="#local-6989586621681181098"><span class="hs-identifier hs-var">unfold_env1</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681181097"><span class="annot"><span class="annottext">TidyOccEnv
</span><a href="#local-6989586621681181097"><span class="hs-identifier hs-var">occ_env1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[(Id, Id)] -&gt; UnfoldEnv -&gt; TidyOccEnv -&gt; IO (UnfoldEnv, TidyOccEnv)
</span><a href="#local-6989586621681181096"><span class="hs-identifier hs-var">search</span></a></span><span> </span><span class="annot"><span class="annottext">[(Id, Id)]
</span><a href="#local-6989586621681181095"><span class="hs-identifier hs-var">init_work_list</span></a></span><span> </span><span class="annot"><span class="annottext">UnfoldEnv
forall a. VarEnv a
</span><a href="GHC.Types.Var.Env.html#emptyVarEnv"><span class="hs-identifier hs-var">emptyVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TidyOccEnv
</span><a href="#local-6989586621681181093"><span class="hs-identifier hs-var">init_occ_env</span></a></span><span>
</span><span id="line-623"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681181092"><span class="annot"><span class="annottext">internal_ids :: [Id]
</span><a href="#local-6989586621681181092"><span class="hs-identifier hs-var hs-var">internal_ids</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Id -&gt; Bool) -&gt; [Id] -&gt; [Id]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">(Bool -&gt; Bool) -&gt; (Id -&gt; Bool) -&gt; Id -&gt; Bool
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; UnfoldEnv -&gt; Bool
forall a. Id -&gt; VarEnv a -&gt; Bool
</span><a href="GHC.Types.Var.Env.html#elemVarEnv"><span class="hs-operator hs-var">`elemVarEnv`</span></a></span><span> </span><span class="annot"><span class="annottext">UnfoldEnv
</span><a href="#local-6989586621681181098"><span class="hs-identifier hs-var">unfold_env1</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681181089"><span class="hs-identifier hs-var">binders</span></a></span><span>
</span><span id="line-624"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; UnfoldEnv -&gt; TidyOccEnv -&gt; IO (UnfoldEnv, TidyOccEnv)
</span><a href="#local-6989586621681181088"><span class="hs-identifier hs-var">tidy_internal</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681181092"><span class="hs-identifier hs-var">internal_ids</span></a></span><span> </span><span class="annot"><span class="annottext">UnfoldEnv
</span><a href="#local-6989586621681181098"><span class="hs-identifier hs-var">unfold_env1</span></a></span><span> </span><span class="annot"><span class="annottext">TidyOccEnv
</span><a href="#local-6989586621681181097"><span class="hs-identifier hs-var">occ_env1</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-625"></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-626"></span><span>  </span><span id="local-6989586621681181087"><span class="annot"><span class="annottext">nc_var :: IORef NameCache
</span><a href="#local-6989586621681181087"><span class="hs-identifier hs-var hs-var">nc_var</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HscEnv -&gt; IORef NameCache
</span><a href="GHC.Driver.Types.html#hsc_NC"><span class="hs-identifier hs-var hs-var">hsc_NC</span></a></span><span> </span><span class="annot"><span class="annottext">HscEnv
</span><a href="#local-6989586621681181105"><span class="hs-identifier hs-var">hsc_env</span></a></span><span>
</span><span id="line-627"></span><span>
</span><span id="line-628"></span><span>  </span><span class="hs-comment">-- init_ext_ids is the initial list of Ids that should be</span><span>
</span><span id="line-629"></span><span>  </span><span class="hs-comment">-- externalised.  It serves as the starting point for finding a</span><span>
</span><span id="line-630"></span><span>  </span><span class="hs-comment">-- deterministic, tidy, renaming for all external Ids in this</span><span>
</span><span id="line-631"></span><span>  </span><span class="hs-comment">-- module.</span><span>
</span><span id="line-632"></span><span>  </span><span class="hs-comment">--</span><span>
</span><span id="line-633"></span><span>  </span><span class="hs-comment">-- It is sorted, so that it has a deterministic order (i.e. it's the</span><span>
</span><span id="line-634"></span><span>  </span><span class="hs-comment">-- same list every time this module is compiled), in contrast to the</span><span>
</span><span id="line-635"></span><span>  </span><span class="hs-comment">-- bindings, which are ordered non-deterministically.</span><span>
</span><span id="line-636"></span><span>  </span><span id="local-6989586621681181095"><span class="annot"><span class="annottext">init_work_list :: [(Id, Id)]
</span><a href="#local-6989586621681181095"><span class="hs-identifier hs-var hs-var">init_work_list</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; [Id] -&gt; [(Id, Id)]
forall a b. [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="../../base/src/GHC.List.html#zip"><span class="hs-identifier hs-var">zip</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681181085"><span class="hs-identifier hs-var">init_ext_ids</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681181085"><span class="hs-identifier hs-var">init_ext_ids</span></a></span><span>
</span><span id="line-637"></span><span>  </span><span id="local-6989586621681181085"><span class="annot"><span class="annottext">init_ext_ids :: [Id]
</span><a href="#local-6989586621681181085"><span class="hs-identifier hs-var hs-var">init_ext_ids</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Id -&gt; Id -&gt; Ordering) -&gt; [Id] -&gt; [Id]
forall a. (a -&gt; a -&gt; Ordering) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/Data.OldList.html#sortBy"><span class="hs-identifier hs-var">sortBy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OccName -&gt; OccName -&gt; Ordering
forall a. Ord a =&gt; a -&gt; a -&gt; Ordering
</span><span class="hs-identifier hs-var">compare</span></span><span> </span><span class="annot"><span class="annottext">(OccName -&gt; OccName -&gt; Ordering)
-&gt; (Id -&gt; OccName) -&gt; Id -&gt; Id -&gt; Ordering
forall b c a. (b -&gt; b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; a -&gt; c
</span><a href="../../base/src/Data.Function.html#on"><span class="hs-operator hs-var">`on`</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; OccName
forall a. NamedThing a =&gt; a -&gt; OccName
</span><a href="GHC.Types.Name.html#getOccName"><span class="hs-identifier hs-var">getOccName</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">([Id] -&gt; [Id]) -&gt; [Id] -&gt; [Id]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(Id -&gt; Bool) -&gt; [Id] -&gt; [Id]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="#local-6989586621681181078"><span class="hs-identifier hs-var">is_external</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681181089"><span class="hs-identifier hs-var">binders</span></a></span><span>
</span><span id="line-638"></span><span>
</span><span id="line-639"></span><span>  </span><span class="hs-comment">-- An Id should be external if either (a) it is exported,</span><span>
</span><span id="line-640"></span><span>  </span><span class="hs-comment">-- (b) it appears in the RHS of a local rule for an imported Id, or</span><span>
</span><span id="line-641"></span><span>  </span><span class="hs-comment">-- See Note [Which rules to expose]</span><span>
</span><span id="line-642"></span><span>  </span><span id="local-6989586621681181078"><span class="annot"><span class="annottext">is_external :: Id -&gt; Bool
</span><a href="#local-6989586621681181078"><span class="hs-identifier hs-var hs-var">is_external</span></a></span></span><span> </span><span id="local-6989586621681181077"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181077"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Var.html#isExportedId"><span class="hs-identifier hs-var">isExportedId</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181077"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181077"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#elemVarSet"><span class="hs-operator hs-var">`elemVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681181074"><span class="hs-identifier hs-var">rule_rhs_vars</span></a></span><span>
</span><span id="line-643"></span><span>
</span><span id="line-644"></span><span>  </span><span id="local-6989586621681181074"><span class="annot"><span class="annottext">rule_rhs_vars :: VarSet
</span><a href="#local-6989586621681181074"><span class="hs-identifier hs-var hs-var">rule_rhs_vars</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CoreRule -&gt; VarSet) -&gt; [CoreRule] -&gt; VarSet
forall a. (a -&gt; VarSet) -&gt; [a] -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#mapUnionVarSet"><span class="hs-identifier hs-var">mapUnionVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">CoreRule -&gt; VarSet
</span><a href="GHC.Core.FVs.html#ruleRhsFreeVars"><span class="hs-identifier hs-var">ruleRhsFreeVars</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621681181099"><span class="hs-identifier hs-var">imp_id_rules</span></a></span><span>
</span><span id="line-645"></span><span>
</span><span id="line-646"></span><span>  </span><span id="local-6989586621681181089"><span class="annot"><span class="annottext">binders :: [Id]
</span><a href="#local-6989586621681181089"><span class="hs-identifier hs-var hs-var">binders</span></a></span></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((Id, Expr Id) -&gt; Id) -&gt; [(Id, Expr Id)] -&gt; [Id]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">(Id, Expr Id) -&gt; Id
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span> </span><span class="annot"><span class="annottext">([(Id, Expr Id)] -&gt; [Id]) -&gt; [(Id, Expr Id)] -&gt; [Id]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">CoreProgram -&gt; [(Id, Expr Id)]
forall b. [Bind b] -&gt; [(b, Expr b)]
</span><a href="GHC.Core.html#flattenBinds"><span class="hs-identifier hs-var">flattenBinds</span></a></span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621681181101"><span class="hs-identifier hs-var">binds</span></a></span><span>
</span><span id="line-647"></span><span>  </span><span id="local-6989586621681181070"><span class="annot"><span class="annottext">implicit_binders :: [Id]
</span><a href="#local-6989586621681181070"><span class="hs-identifier hs-var hs-var">implicit_binders</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreProgram -&gt; [Id]
forall b. [Bind b] -&gt; [b]
</span><a href="GHC.Core.html#bindersOfBinds"><span class="hs-identifier hs-var">bindersOfBinds</span></a></span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621681181100"><span class="hs-identifier hs-var">implicit_binds</span></a></span><span>
</span><span id="line-648"></span><span>  </span><span id="local-6989586621681181069"><span class="annot"><span class="annottext">binder_set :: VarSet
</span><a href="#local-6989586621681181069"><span class="hs-identifier hs-var hs-var">binder_set</span></a></span></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#mkVarSet"><span class="hs-identifier hs-var">mkVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681181089"><span class="hs-identifier hs-var">binders</span></a></span><span>
</span><span id="line-649"></span><span>
</span><span id="line-650"></span><span>  </span><span id="local-6989586621681181065"><span class="annot"><span class="annottext">avoids :: [OccName]
</span><a href="#local-6989586621681181065"><span class="hs-identifier hs-var hs-var">avoids</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Name -&gt; OccName
forall a. NamedThing a =&gt; a -&gt; OccName
</span><a href="GHC.Types.Name.html#getOccName"><span class="hs-identifier hs-var">getOccName</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681181064"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621681181063"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181063"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681181089"><span class="hs-identifier hs-var">binders</span></a></span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; [Id] -&gt; [Id]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681181070"><span class="hs-identifier hs-var">implicit_binders</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-651"></span><span>                                </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681181064"><span class="annot"><span class="annottext">name :: Name
</span><a href="#local-6989586621681181064"><span class="hs-identifier hs-var hs-var">name</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Name
</span><a href="GHC.Types.Id.html#idName"><span class="hs-identifier hs-var">idName</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181063"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-652"></span><span>                                </span><span class="annot"><span class="annottext">Name -&gt; Bool
</span><a href="GHC.Types.Name.html#isExternalName"><span class="hs-identifier hs-var">isExternalName</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681181064"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-653"></span><span>                </span><span class="hs-comment">-- In computing our &quot;avoids&quot; list, we must include</span><span>
</span><span id="line-654"></span><span>                </span><span class="hs-comment">--      all implicit Ids</span><span>
</span><span id="line-655"></span><span>                </span><span class="hs-comment">--      all things with global names (assigned once and for</span><span>
</span><span id="line-656"></span><span>                </span><span class="hs-comment">--                                      all by the renamer)</span><span>
</span><span id="line-657"></span><span>                </span><span class="hs-comment">-- since their names are &quot;taken&quot;.</span><span>
</span><span id="line-658"></span><span>                </span><span class="hs-comment">-- The type environment is a convenient source of such things.</span><span>
</span><span id="line-659"></span><span>                </span><span class="hs-comment">-- In particular, the set of binders doesn't include</span><span>
</span><span id="line-660"></span><span>                </span><span class="hs-comment">-- implicit Ids at this stage.</span><span>
</span><span id="line-661"></span><span>
</span><span id="line-662"></span><span>        </span><span class="hs-comment">-- We also make sure to avoid any exported binders.  Consider</span><span>
</span><span id="line-663"></span><span>        </span><span class="hs-comment">--      f{-u1-} = 1     -- Local decl</span><span>
</span><span id="line-664"></span><span>        </span><span class="hs-comment">--      ...</span><span>
</span><span id="line-665"></span><span>        </span><span class="hs-comment">--      f{-u2-} = 2     -- Exported decl</span><span>
</span><span id="line-666"></span><span>        </span><span class="hs-comment">--</span><span>
</span><span id="line-667"></span><span>        </span><span class="hs-comment">-- The second exported decl must 'get' the name 'f', so we</span><span>
</span><span id="line-668"></span><span>        </span><span class="hs-comment">-- have to put 'f' in the avoids list before we get to the first</span><span>
</span><span id="line-669"></span><span>        </span><span class="hs-comment">-- decl.  tidyTopId then does a no-op on exported binders.</span><span>
</span><span id="line-670"></span><span>  </span><span id="local-6989586621681181093"><span class="annot"><span class="annottext">init_occ_env :: TidyOccEnv
</span><a href="#local-6989586621681181093"><span class="hs-identifier hs-var hs-var">init_occ_env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[OccName] -&gt; TidyOccEnv
</span><a href="GHC.Types.Name.Occurrence.html#initTidyOccEnv"><span class="hs-identifier hs-var">initTidyOccEnv</span></a></span><span> </span><span class="annot"><span class="annottext">[OccName]
</span><a href="#local-6989586621681181065"><span class="hs-identifier hs-var">avoids</span></a></span><span>
</span><span id="line-671"></span><span>
</span><span id="line-672"></span><span>
</span><span id="line-673"></span><span>  </span><span class="annot"><a href="#local-6989586621681181096"><span class="hs-identifier hs-type">search</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>    </span><span class="hs-comment">-- The work-list: (external id, referring id)</span><span>
</span><span id="line-674"></span><span>                         </span><span class="hs-comment">-- Make a tidy, external Name for the external id,</span><span>
</span><span id="line-675"></span><span>                         </span><span class="hs-comment">--   add it to the UnfoldEnv, and do the same for the</span><span>
</span><span id="line-676"></span><span>                         </span><span class="hs-comment">--   transitive closure of Ids it refers to</span><span>
</span><span id="line-677"></span><span>                         </span><span class="hs-comment">-- The referring id is used to generate a tidy</span><span>
</span><span id="line-678"></span><span>                         </span><span class="hs-comment">---  name for the external id</span><span>
</span><span id="line-679"></span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Iface.Tidy.html#UnfoldEnv"><span class="hs-identifier hs-type">UnfoldEnv</span></a></span><span>    </span><span class="hs-comment">-- id -&gt; (new Name, show_unfold)</span><span>
</span><span id="line-680"></span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Name.Occurrence.html#TidyOccEnv"><span class="hs-identifier hs-type">TidyOccEnv</span></a></span><span>   </span><span class="hs-comment">-- occ env for choosing new Names</span><span>
</span><span id="line-681"></span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Iface.Tidy.html#UnfoldEnv"><span class="hs-identifier hs-type">UnfoldEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Name.Occurrence.html#TidyOccEnv"><span class="hs-identifier hs-type">TidyOccEnv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-682"></span><span>
</span><span id="line-683"></span><span>  </span><span id="local-6989586621681181096"><span class="annot"><span class="annottext">search :: [(Id, Id)] -&gt; UnfoldEnv -&gt; TidyOccEnv -&gt; IO (UnfoldEnv, TidyOccEnv)
</span><a href="#local-6989586621681181096"><span class="hs-identifier hs-var hs-var">search</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span id="local-6989586621681181061"><span class="annot"><span class="annottext">UnfoldEnv
</span><a href="#local-6989586621681181061"><span class="hs-identifier hs-var">unfold_env</span></a></span></span><span> </span><span id="local-6989586621681181060"><span class="annot"><span class="annottext">TidyOccEnv
</span><a href="#local-6989586621681181060"><span class="hs-identifier hs-var">occ_env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(UnfoldEnv, TidyOccEnv) -&gt; IO (UnfoldEnv, TidyOccEnv)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UnfoldEnv
</span><a href="#local-6989586621681181061"><span class="hs-identifier hs-var">unfold_env</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TidyOccEnv
</span><a href="#local-6989586621681181060"><span class="hs-identifier hs-var">occ_env</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-684"></span><span>
</span><span id="line-685"></span><span>  </span><span class="annot"><a href="#local-6989586621681181096"><span class="hs-identifier hs-var">search</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span id="local-6989586621681181059"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181059"><span class="hs-identifier hs-var">idocc</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681181058"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181058"><span class="hs-identifier hs-var">referrer</span></a></span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621681181057"><span class="annot"><span class="annottext">[(Id, Id)]
</span><a href="#local-6989586621681181057"><span class="hs-identifier hs-var">rest</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681181056"><span class="annot"><span class="annottext">UnfoldEnv
</span><a href="#local-6989586621681181056"><span class="hs-identifier hs-var">unfold_env</span></a></span></span><span> </span><span id="local-6989586621681181055"><span class="annot"><span class="annottext">TidyOccEnv
</span><a href="#local-6989586621681181055"><span class="hs-identifier hs-var">occ_env</span></a></span></span><span>
</span><span id="line-686"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181059"><span class="hs-identifier hs-var">idocc</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; UnfoldEnv -&gt; Bool
forall a. Id -&gt; VarEnv a -&gt; Bool
</span><a href="GHC.Types.Var.Env.html#elemVarEnv"><span class="hs-operator hs-var">`elemVarEnv`</span></a></span><span> </span><span class="annot"><span class="annottext">UnfoldEnv
</span><a href="#local-6989586621681181056"><span class="hs-identifier hs-var">unfold_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(Id, Id)] -&gt; UnfoldEnv -&gt; TidyOccEnv -&gt; IO (UnfoldEnv, TidyOccEnv)
</span><a href="#local-6989586621681181096"><span class="hs-identifier hs-var">search</span></a></span><span> </span><span class="annot"><span class="annottext">[(Id, Id)]
</span><a href="#local-6989586621681181057"><span class="hs-identifier hs-var">rest</span></a></span><span> </span><span class="annot"><span class="annottext">UnfoldEnv
</span><a href="#local-6989586621681181056"><span class="hs-identifier hs-var">unfold_env</span></a></span><span> </span><span class="annot"><span class="annottext">TidyOccEnv
</span><a href="#local-6989586621681181055"><span class="hs-identifier hs-var">occ_env</span></a></span><span>
</span><span id="line-687"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-688"></span><span>      </span><span class="hs-special">(</span><span id="local-6989586621681181054"><span class="annot"><span class="annottext">TidyOccEnv
</span><a href="#local-6989586621681181054"><span class="hs-identifier hs-var">occ_env'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681181053"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681181053"><span class="hs-identifier hs-var">name'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Module
-&gt; IORef NameCache
-&gt; Maybe Id
-&gt; TidyOccEnv
-&gt; Id
-&gt; IO (TidyOccEnv, Name)
</span><a href="GHC.Iface.Tidy.html#tidyTopName"><span class="hs-identifier hs-var">tidyTopName</span></a></span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681181104"><span class="hs-identifier hs-var">mod</span></a></span><span> </span><span class="annot"><span class="annottext">IORef NameCache
</span><a href="#local-6989586621681181087"><span class="hs-identifier hs-var">nc_var</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Maybe Id
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181058"><span class="hs-identifier hs-var">referrer</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TidyOccEnv
</span><a href="#local-6989586621681181055"><span class="hs-identifier hs-var">occ_env</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181059"><span class="hs-identifier hs-var">idocc</span></a></span><span>
</span><span id="line-689"></span><span>      </span><span class="hs-keyword">let</span><span>
</span><span id="line-690"></span><span>          </span><span class="hs-special">(</span><span id="local-6989586621681181051"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681181051"><span class="hs-identifier hs-var">new_ids</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681181050"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681181050"><span class="hs-identifier hs-var">show_unfold</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Id -&gt; ([Id], Bool)
</span><a href="GHC.Iface.Tidy.html#addExternal"><span class="hs-identifier hs-var">addExternal</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681181103"><span class="hs-identifier hs-var">omit_prags</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681181102"><span class="hs-identifier hs-var">expose_all</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181048"><span class="hs-identifier hs-var">refined_id</span></a></span><span>
</span><span id="line-691"></span><span>
</span><span id="line-692"></span><span>                </span><span class="hs-comment">-- 'idocc' is an *occurrence*, but we need to see the</span><span>
</span><span id="line-693"></span><span>                </span><span class="hs-comment">-- unfolding in the *definition*; so look up in binder_set</span><span>
</span><span id="line-694"></span><span>          </span><span id="local-6989586621681181048"><span class="annot"><span class="annottext">refined_id :: Id
</span><a href="#local-6989586621681181048"><span class="hs-identifier hs-var hs-var">refined_id</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; Id -&gt; Maybe Id
</span><a href="GHC.Types.Var.Set.html#lookupVarSet"><span class="hs-identifier hs-var">lookupVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681181069"><span class="hs-identifier hs-var">binder_set</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181059"><span class="hs-identifier hs-var">idocc</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-695"></span><span>                         </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681181043"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181043"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181043"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-696"></span><span>                         </span><span class="annot"><span class="annottext">Maybe Id
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">WARN</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">True</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">idocc</span><span> </span><span class="hs-special">)</span><span> </span><span class="hs-identifier">idocc</span><span>
</span><span id="line-697"></span><span>
</span><span id="line-698"></span><span>          </span><span id="local-6989586621681181041"><span class="annot"><span class="annottext">unfold_env' :: UnfoldEnv
</span><a href="#local-6989586621681181041"><span class="hs-identifier hs-var hs-var">unfold_env'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UnfoldEnv -&gt; Id -&gt; (Name, Bool) -&gt; UnfoldEnv
forall a. VarEnv a -&gt; Id -&gt; a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#extendVarEnv"><span class="hs-identifier hs-var">extendVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">UnfoldEnv
</span><a href="#local-6989586621681181056"><span class="hs-identifier hs-var">unfold_env</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181059"><span class="hs-identifier hs-var">idocc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681181053"><span class="hs-identifier hs-var">name'</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681181050"><span class="hs-identifier hs-var">show_unfold</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-699"></span><span>          </span><span id="local-6989586621681181039"><span class="annot"><span class="annottext">referrer' :: Id
</span><a href="#local-6989586621681181039"><span class="hs-identifier hs-var hs-var">referrer'</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Var.html#isExportedId"><span class="hs-identifier hs-var">isExportedId</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181048"><span class="hs-identifier hs-var">refined_id</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181048"><span class="hs-identifier hs-var">refined_id</span></a></span><span>
</span><span id="line-700"></span><span>                    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>               </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181058"><span class="hs-identifier hs-var">referrer</span></a></span><span>
</span><span id="line-701"></span><span>      </span><span class="hs-comment">--</span><span>
</span><span id="line-702"></span><span>      </span><span class="annot"><span class="annottext">[(Id, Id)] -&gt; UnfoldEnv -&gt; TidyOccEnv -&gt; IO (UnfoldEnv, TidyOccEnv)
</span><a href="#local-6989586621681181096"><span class="hs-identifier hs-var">search</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id] -&gt; [Id] -&gt; [(Id, Id)]
forall a b. [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="../../base/src/GHC.List.html#zip"><span class="hs-identifier hs-var">zip</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681181051"><span class="hs-identifier hs-var">new_ids</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; [Id]
forall a. a -&gt; [a]
</span><a href="../../base/src/GHC.List.html#repeat"><span class="hs-identifier hs-var">repeat</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181039"><span class="hs-identifier hs-var">referrer'</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(Id, Id)] -&gt; [(Id, Id)] -&gt; [(Id, Id)]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[(Id, Id)]
</span><a href="#local-6989586621681181057"><span class="hs-identifier hs-var">rest</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">UnfoldEnv
</span><a href="#local-6989586621681181041"><span class="hs-identifier hs-var">unfold_env'</span></a></span><span> </span><span class="annot"><span class="annottext">TidyOccEnv
</span><a href="#local-6989586621681181054"><span class="hs-identifier hs-var">occ_env'</span></a></span><span>
</span><span id="line-703"></span><span>
</span><span id="line-704"></span><span>  </span><span class="annot"><a href="#local-6989586621681181088"><span class="hs-identifier hs-type">tidy_internal</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Iface.Tidy.html#UnfoldEnv"><span class="hs-identifier hs-type">UnfoldEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Name.Occurrence.html#TidyOccEnv"><span class="hs-identifier hs-type">TidyOccEnv</span></a></span><span>
</span><span id="line-705"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Iface.Tidy.html#UnfoldEnv"><span class="hs-identifier hs-type">UnfoldEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Name.Occurrence.html#TidyOccEnv"><span class="hs-identifier hs-type">TidyOccEnv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-706"></span><span>  </span><span id="local-6989586621681181088"><span class="annot"><span class="annottext">tidy_internal :: [Id] -&gt; UnfoldEnv -&gt; TidyOccEnv -&gt; IO (UnfoldEnv, TidyOccEnv)
</span><a href="#local-6989586621681181088"><span class="hs-identifier hs-var hs-var">tidy_internal</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>       </span><span id="local-6989586621681181037"><span class="annot"><span class="annottext">UnfoldEnv
</span><a href="#local-6989586621681181037"><span class="hs-identifier hs-var">unfold_env</span></a></span></span><span> </span><span id="local-6989586621681181036"><span class="annot"><span class="annottext">TidyOccEnv
</span><a href="#local-6989586621681181036"><span class="hs-identifier hs-var">occ_env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(UnfoldEnv, TidyOccEnv) -&gt; IO (UnfoldEnv, TidyOccEnv)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UnfoldEnv
</span><a href="#local-6989586621681181037"><span class="hs-identifier hs-var">unfold_env</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">TidyOccEnv
</span><a href="#local-6989586621681181036"><span class="hs-identifier hs-var">occ_env</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-707"></span><span>  </span><span class="annot"><a href="#local-6989586621681181088"><span class="hs-identifier hs-var">tidy_internal</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681181035"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181035"><span class="hs-identifier hs-var">id</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621681181034"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681181034"><span class="hs-identifier hs-var">ids</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681181033"><span class="annot"><span class="annottext">UnfoldEnv
</span><a href="#local-6989586621681181033"><span class="hs-identifier hs-var">unfold_env</span></a></span></span><span> </span><span id="local-6989586621681181032"><span class="annot"><span class="annottext">TidyOccEnv
</span><a href="#local-6989586621681181032"><span class="hs-identifier hs-var">occ_env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-708"></span><span>      </span><span class="hs-special">(</span><span id="local-6989586621681181031"><span class="annot"><span class="annottext">TidyOccEnv
</span><a href="#local-6989586621681181031"><span class="hs-identifier hs-var">occ_env'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681181030"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681181030"><span class="hs-identifier hs-var">name'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Module
-&gt; IORef NameCache
-&gt; Maybe Id
-&gt; TidyOccEnv
-&gt; Id
-&gt; IO (TidyOccEnv, Name)
</span><a href="GHC.Iface.Tidy.html#tidyTopName"><span class="hs-identifier hs-var">tidyTopName</span></a></span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681181104"><span class="hs-identifier hs-var">mod</span></a></span><span> </span><span class="annot"><span class="annottext">IORef NameCache
</span><a href="#local-6989586621681181087"><span class="hs-identifier hs-var">nc_var</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Id
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="annot"><span class="annottext">TidyOccEnv
</span><a href="#local-6989586621681181032"><span class="hs-identifier hs-var">occ_env</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181035"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-709"></span><span>      </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681181029"><span class="annot"><span class="annottext">unfold_env' :: UnfoldEnv
</span><a href="#local-6989586621681181029"><span class="hs-identifier hs-var hs-var">unfold_env'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UnfoldEnv -&gt; Id -&gt; (Name, Bool) -&gt; UnfoldEnv
forall a. VarEnv a -&gt; Id -&gt; a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#extendVarEnv"><span class="hs-identifier hs-var">extendVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">UnfoldEnv
</span><a href="#local-6989586621681181033"><span class="hs-identifier hs-var">unfold_env</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181035"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681181030"><span class="hs-identifier hs-var">name'</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">)</span><span>
</span><span id="line-710"></span><span>      </span><span class="annot"><span class="annottext">[Id] -&gt; UnfoldEnv -&gt; TidyOccEnv -&gt; IO (UnfoldEnv, TidyOccEnv)
</span><a href="#local-6989586621681181088"><span class="hs-identifier hs-var">tidy_internal</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681181034"><span class="hs-identifier hs-var">ids</span></a></span><span> </span><span class="annot"><span class="annottext">UnfoldEnv
</span><a href="#local-6989586621681181029"><span class="hs-identifier hs-var">unfold_env'</span></a></span><span> </span><span class="annot"><span class="annottext">TidyOccEnv
</span><a href="#local-6989586621681181031"><span class="hs-identifier hs-var">occ_env'</span></a></span><span>
</span><span id="line-711"></span><span>
</span><span id="line-712"></span><span class="annot"><a href="GHC.Iface.Tidy.html#addExternal"><span class="hs-identifier hs-type">addExternal</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span class="hs-special">)</span><span>
</span><span id="line-713"></span><span id="addExternal"><span class="annot"><span class="annottext">addExternal :: Bool -&gt; Bool -&gt; Id -&gt; ([Id], Bool)
</span><a href="GHC.Iface.Tidy.html#addExternal"><span class="hs-identifier hs-var hs-var">addExternal</span></a></span></span><span> </span><span id="local-6989586621681181028"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681181028"><span class="hs-identifier hs-var">omit_prags</span></a></span></span><span> </span><span id="local-6989586621681181027"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681181027"><span class="hs-identifier hs-var">expose_all</span></a></span></span><span> </span><span id="local-6989586621681181026"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181026"><span class="hs-identifier hs-var">id</span></a></span></span><span>
</span><span id="line-714"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681181028"><span class="hs-identifier hs-var">omit_prags</span></a></span><span>
</span><span id="line-715"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Unfolding -&gt; Bool
</span><a href="GHC.Core.html#isCompulsoryUnfolding"><span class="hs-identifier hs-var">isCompulsoryUnfolding</span></a></span><span> </span><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621681181024"><span class="hs-identifier hs-var">unfolding</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-716"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- See Note [Always expose compulsory unfoldings]</span><span>
</span><span id="line-717"></span><span>                 </span><span class="hs-comment">-- in GHC.HsToCore</span><span>
</span><span id="line-718"></span><span>
</span><span id="line-719"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-720"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681181023"><span class="hs-identifier hs-var">new_needed_ids</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681181022"><span class="hs-identifier hs-var">show_unfold</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-721"></span><span>
</span><span id="line-722"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-723"></span><span>    </span><span id="local-6989586621681181023"><span class="annot"><span class="annottext">new_needed_ids :: [Id]
</span><a href="#local-6989586621681181023"><span class="hs-identifier hs-var hs-var">new_needed_ids</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Id -&gt; [Id]
</span><a href="GHC.Iface.Tidy.html#bndrFvsInOrder"><span class="hs-identifier hs-var">bndrFvsInOrder</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681181022"><span class="hs-identifier hs-var">show_unfold</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181026"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-724"></span><span>    </span><span id="local-6989586621681181018"><span class="annot"><span class="annottext">idinfo :: IdInfo
</span><a href="#local-6989586621681181018"><span class="hs-identifier hs-var hs-var">idinfo</span></a></span></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Id -&gt; IdInfo
Id -&gt; IdInfo
</span><a href="GHC.Types.Var.html#idInfo"><span class="hs-identifier hs-var">idInfo</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681181026"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-725"></span><span>    </span><span id="local-6989586621681181024"><span class="annot"><span class="annottext">unfolding :: Unfolding
</span><a href="#local-6989586621681181024"><span class="hs-identifier hs-var hs-var">unfolding</span></a></span></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IdInfo -&gt; Unfolding
</span><a href="GHC.Types.Id.Info.html#unfoldingInfo"><span class="hs-identifier hs-var hs-var">unfoldingInfo</span></a></span><span> </span><span class="annot"><span class="annottext">IdInfo
</span><a href="#local-6989586621681181018"><span class="hs-identifier hs-var">idinfo</span></a></span><span>
</span><span id="line-726"></span><span>    </span><span id="local-6989586621681181022"><span class="annot"><span class="annottext">show_unfold :: Bool
</span><a href="#local-6989586621681181022"><span class="hs-identifier hs-var hs-var">show_unfold</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Unfolding -&gt; Bool
</span><a href="#local-6989586621681181015"><span class="hs-identifier hs-var">show_unfolding</span></a></span><span> </span><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621681181024"><span class="hs-identifier hs-var">unfolding</span></a></span><span>
</span><span id="line-727"></span><span>    </span><span id="local-6989586621681181014"><span class="annot"><span class="annottext">never_active :: Bool
</span><a href="#local-6989586621681181014"><span class="hs-identifier hs-var hs-var">never_active</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Activation -&gt; Bool
</span><a href="GHC.Types.Basic.html#isNeverActive"><span class="hs-identifier hs-var">isNeverActive</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InlinePragma -&gt; Activation
</span><a href="GHC.Types.Basic.html#inlinePragmaActivation"><span class="hs-identifier hs-var">inlinePragmaActivation</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IdInfo -&gt; InlinePragma
</span><a href="GHC.Types.Id.Info.html#inlinePragInfo"><span class="hs-identifier hs-var hs-var">inlinePragInfo</span></a></span><span> </span><span class="annot"><span class="annottext">IdInfo
</span><a href="#local-6989586621681181018"><span class="hs-identifier hs-var">idinfo</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-728"></span><span>    </span><span id="local-6989586621681181010"><span class="annot"><span class="annottext">loop_breaker :: Bool
</span><a href="#local-6989586621681181010"><span class="hs-identifier hs-var hs-var">loop_breaker</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccInfo -&gt; Bool
</span><a href="GHC.Types.Basic.html#isStrongLoopBreaker"><span class="hs-identifier hs-var">isStrongLoopBreaker</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IdInfo -&gt; OccInfo
</span><a href="GHC.Types.Id.Info.html#occInfo"><span class="hs-identifier hs-var hs-var">occInfo</span></a></span><span> </span><span class="annot"><span class="annottext">IdInfo
</span><a href="#local-6989586621681181018"><span class="hs-identifier hs-var">idinfo</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-729"></span><span>    </span><span id="local-6989586621681181007"><span class="annot"><span class="annottext">bottoming_fn :: Bool
</span><a href="#local-6989586621681181007"><span class="hs-identifier hs-var hs-var">bottoming_fn</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StrictSig -&gt; Bool
</span><a href="GHC.Types.Demand.html#isDeadEndSig"><span class="hs-identifier hs-var">isDeadEndSig</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IdInfo -&gt; StrictSig
</span><a href="GHC.Types.Id.Info.html#strictnessInfo"><span class="hs-identifier hs-var hs-var">strictnessInfo</span></a></span><span> </span><span class="annot"><span class="annottext">IdInfo
</span><a href="#local-6989586621681181018"><span class="hs-identifier hs-var">idinfo</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-730"></span><span>
</span><span id="line-731"></span><span>        </span><span class="hs-comment">-- Stuff to do with the Id's unfolding</span><span>
</span><span id="line-732"></span><span>        </span><span class="hs-comment">-- We leave the unfolding there even if there is a worker</span><span>
</span><span id="line-733"></span><span>        </span><span class="hs-comment">-- In GHCi the unfolding is used by importers</span><span>
</span><span id="line-734"></span><span>
</span><span id="line-735"></span><span>    </span><span id="local-6989586621681181015"><span class="annot"><span class="annottext">show_unfolding :: Unfolding -&gt; Bool
</span><a href="#local-6989586621681181015"><span class="hs-identifier hs-var hs-var">show_unfolding</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#CoreUnfolding"><span class="hs-identifier hs-type">CoreUnfolding</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">uf_src :: Unfolding -&gt; UnfoldingSource
</span><a href="GHC.Core.html#uf_src"><span class="hs-identifier hs-var">uf_src</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681181003"><span class="annot"><span class="annottext">UnfoldingSource
</span><a href="#local-6989586621681181003"><span class="hs-identifier hs-var">src</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">uf_guidance :: Unfolding -&gt; UnfoldingGuidance
</span><a href="GHC.Core.html#uf_guidance"><span class="hs-identifier hs-var">uf_guidance</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681181001"><span class="annot"><span class="annottext">UnfoldingGuidance
</span><a href="#local-6989586621681181001"><span class="hs-identifier hs-var">guidance</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-736"></span><span>       </span><span class="hs-glyph">=</span><span>  </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681181027"><span class="hs-identifier hs-var">expose_all</span></a></span><span>         </span><span class="hs-comment">-- 'expose_all' says to expose all</span><span>
</span><span id="line-737"></span><span>                             </span><span class="hs-comment">-- unfoldings willy-nilly</span><span>
</span><span id="line-738"></span><span>
</span><span id="line-739"></span><span>       </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">UnfoldingSource -&gt; Bool
</span><a href="GHC.Core.html#isStableSource"><span class="hs-identifier hs-var">isStableSource</span></a></span><span> </span><span class="annot"><span class="annottext">UnfoldingSource
</span><a href="#local-6989586621681181003"><span class="hs-identifier hs-var">src</span></a></span><span>     </span><span class="hs-comment">-- Always expose things whose</span><span>
</span><span id="line-740"></span><span>                                 </span><span class="hs-comment">-- source is an inline rule</span><span>
</span><span id="line-741"></span><span>
</span><span id="line-742"></span><span>       </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681181007"><span class="hs-identifier hs-var">bottoming_fn</span></a></span><span>      </span><span class="hs-comment">-- No need to inline bottom functions</span><span>
</span><span id="line-743"></span><span>           </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681181014"><span class="hs-identifier hs-var">never_active</span></a></span><span>       </span><span class="hs-comment">-- Or ones that say not to</span><span>
</span><span id="line-744"></span><span>           </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681181010"><span class="hs-identifier hs-var">loop_breaker</span></a></span><span>       </span><span class="hs-comment">-- Or that are loop breakers</span><span>
</span><span id="line-745"></span><span>           </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">UnfoldingGuidance -&gt; Bool
</span><a href="GHC.Core.html#neverUnfoldGuidance"><span class="hs-identifier hs-var">neverUnfoldGuidance</span></a></span><span> </span><span class="annot"><span class="annottext">UnfoldingGuidance
</span><a href="#local-6989586621681181001"><span class="hs-identifier hs-var">guidance</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-746"></span><span>    </span><span class="annot"><a href="#local-6989586621681181015"><span class="hs-identifier hs-var">show_unfolding</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#DFunUnfolding"><span class="hs-identifier hs-type">DFunUnfolding</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-747"></span><span>    </span><span class="annot"><a href="#local-6989586621681181015"><span class="hs-identifier hs-var">show_unfolding</span></a></span><span> </span><span class="annot"><span class="annottext">Unfolding
</span><span class="hs-identifier">_</span></span><span>                  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-748"></span><span>
</span><span id="line-749"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
               Deterministic free variables
*                                                                      *
************************************************************************

We want a deterministic free-variable list.  exprFreeVars gives us
a VarSet, which is in a non-deterministic order when converted to a
list.  Hence, here we define a free-variable finder that returns
the free variables in the order that they are encountered.

See Note [Choosing external Ids]
-}</span><span>
</span><span id="line-763"></span><span>
</span><span id="line-764"></span><span class="annot"><a href="GHC.Iface.Tidy.html#bndrFvsInOrder"><span class="hs-identifier hs-type">bndrFvsInOrder</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-765"></span><span id="bndrFvsInOrder"><span class="annot"><span class="annottext">bndrFvsInOrder :: Bool -&gt; Id -&gt; [Id]
</span><a href="GHC.Iface.Tidy.html#bndrFvsInOrder"><span class="hs-identifier hs-var hs-var">bndrFvsInOrder</span></a></span></span><span> </span><span id="local-6989586621681180997"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681180997"><span class="hs-identifier hs-var">show_unfold</span></a></span></span><span> </span><span id="local-6989586621681180996"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180996"><span class="hs-identifier hs-var">id</span></a></span></span><span>
</span><span id="line-766"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DFFV () -&gt; [Id]
</span><a href="GHC.Iface.Tidy.html#run"><span class="hs-identifier hs-var">run</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; Id -&gt; DFFV ()
</span><a href="GHC.Iface.Tidy.html#dffvLetBndr"><span class="hs-identifier hs-var">dffvLetBndr</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681180997"><span class="hs-identifier hs-var">show_unfold</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180996"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-767"></span><span>
</span><span id="line-768"></span><span class="annot"><a href="GHC.Iface.Tidy.html#run"><span class="hs-identifier hs-type">run</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Iface.Tidy.html#DFFV"><span class="hs-identifier hs-type">DFFV</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-769"></span><span id="run"><span class="annot"><span class="annottext">run :: DFFV () -&gt; [Id]
</span><a href="GHC.Iface.Tidy.html#run"><span class="hs-identifier hs-var hs-var">run</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Iface.Tidy.html#DFFV"><span class="hs-identifier hs-type">DFFV</span></a></span><span> </span><span id="local-6989586621681180992"><span class="annot"><span class="annottext">VarSet -&gt; (VarSet, [Id]) -&gt; ((VarSet, [Id]), ())
</span><a href="#local-6989586621681180992"><span class="hs-identifier hs-var">m</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; (VarSet, [Id]) -&gt; ((VarSet, [Id]), ())
</span><a href="#local-6989586621681180992"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="GHC.Types.Var.Set.html#emptyVarSet"><span class="hs-identifier hs-var">emptyVarSet</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet
</span><a href="GHC.Types.Var.Set.html#emptyVarSet"><span class="hs-identifier hs-var">emptyVarSet</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-770"></span><span>                 </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span id="local-6989586621681180990"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681180990"><span class="hs-identifier hs-var">ids</span></a></span></span><span class="hs-special">)</span><span class="hs-special">,</span><span class="annot"><span class="annottext">()
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681180990"><span class="hs-identifier hs-var">ids</span></a></span><span>
</span><span id="line-771"></span><span>
</span><span id="line-772"></span><span class="hs-keyword">newtype</span><span> </span><span id="DFFV"><span class="annot"><a href="GHC.Iface.Tidy.html#DFFV"><span class="hs-identifier hs-var">DFFV</span></a></span></span><span> </span><span id="local-6989586621681181465"><span class="annot"><a href="#local-6989586621681181465"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-773"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="DFFV"><span class="annot"><a href="GHC.Iface.Tidy.html#DFFV"><span class="hs-identifier hs-var">DFFV</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span>              </span><span class="hs-comment">-- Envt: non-top-level things that are in scope</span><span>
</span><span id="line-774"></span><span>                              </span><span class="hs-comment">-- we don't want to record these as free vars</span><span>
</span><span id="line-775"></span><span>      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>      </span><span class="hs-comment">-- Input State: (set, list) of free vars so far</span><span>
</span><span id="line-776"></span><span>      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span class="hs-special">,</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span class="hs-special">,</span><span class="annot"><a href="#local-6989586621681181465"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- Output state</span><span>
</span><span id="line-777"></span><span>    </span><span class="hs-keyword">deriving</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681180985"><span id="local-6989586621681180987"><span class="annot"><span class="annottext">(forall a b. (a -&gt; b) -&gt; DFFV a -&gt; DFFV b)
-&gt; (forall a b. a -&gt; DFFV b -&gt; DFFV a) -&gt; Functor DFFV
forall a b. a -&gt; DFFV b -&gt; DFFV a
forall a b. (a -&gt; b) -&gt; DFFV a -&gt; DFFV b
forall (f :: * -&gt; *).
(forall a b. (a -&gt; b) -&gt; f a -&gt; f b)
-&gt; (forall a b. a -&gt; f b -&gt; f a) -&gt; Functor f
&lt;$ :: forall a b. a -&gt; DFFV b -&gt; DFFV a
$c&lt;$ :: forall a b. a -&gt; DFFV b -&gt; DFFV a
fmap :: forall a b. (a -&gt; b) -&gt; DFFV a -&gt; DFFV b
$cfmap :: forall a b. (a -&gt; b) -&gt; DFFV a -&gt; DFFV b
</span><a href="../../base/src/GHC.Base.html#Functor"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var">Functor</span></a></span></span></span><span class="hs-special">)</span><span>
</span><span id="line-778"></span><span>
</span><span id="line-779"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621681180973"><span id="local-6989586621681180975"><span id="local-6989586621681180977"><span class="annot"><a href="../../base/src/GHC.Base.html#Applicative"><span class="hs-identifier hs-type">Applicative</span></a></span><span> </span><span class="annot"><a href="GHC.Iface.Tidy.html#DFFV"><span class="hs-identifier hs-type">DFFV</span></a></span></span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-780"></span><span>    </span><span id="local-6989586621681180971"><span class="annot"><span class="annottext">pure :: forall a. a -&gt; DFFV a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var hs-var hs-var hs-var">pure</span></a></span></span><span> </span><span id="local-6989586621681180970"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681180970"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(VarSet -&gt; (VarSet, [Id]) -&gt; ((VarSet, [Id]), a)) -&gt; DFFV a
forall a.
(VarSet -&gt; (VarSet, [Id]) -&gt; ((VarSet, [Id]), a)) -&gt; DFFV a
</span><a href="GHC.Iface.Tidy.html#DFFV"><span class="hs-identifier hs-var">DFFV</span></a></span><span> </span><span class="annot"><span class="annottext">((VarSet -&gt; (VarSet, [Id]) -&gt; ((VarSet, [Id]), a)) -&gt; DFFV a)
-&gt; (VarSet -&gt; (VarSet, [Id]) -&gt; ((VarSet, [Id]), a)) -&gt; DFFV a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span class="annot"><span class="annottext">VarSet
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681180969"><span class="annot"><span class="annottext">(VarSet, [Id])
</span><a href="#local-6989586621681180969"><span class="hs-identifier hs-var">st</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(VarSet, [Id])
</span><a href="#local-6989586621681180969"><span class="hs-identifier hs-var">st</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681180970"><span class="hs-identifier hs-var">a</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-781"></span><span>    </span><span id="local-6989586621681180967"><span class="annot"><span class="annottext">&lt;*&gt; :: forall a b. DFFV (a -&gt; b) -&gt; DFFV a -&gt; DFFV b
</span><a href="../../base/src/GHC.Base.html#%3C%2A%3E"><span class="hs-operator hs-var hs-var hs-var hs-var">(&lt;*&gt;)</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DFFV (a -&gt; b) -&gt; DFFV a -&gt; DFFV b
forall (m :: * -&gt; *) a b. Monad m =&gt; m (a -&gt; b) -&gt; m a -&gt; m b
</span><a href="../../base/src/GHC.Base.html#ap"><span class="hs-identifier hs-var">ap</span></a></span><span>
</span><span id="line-782"></span><span>
</span><span id="line-783"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621681180959"><span id="local-6989586621681180961"><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="annot"><a href="GHC.Iface.Tidy.html#DFFV"><span class="hs-identifier hs-type">DFFV</span></a></span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-784"></span><span>  </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Iface.Tidy.html#DFFV"><span class="hs-identifier hs-type">DFFV</span></a></span><span> </span><span id="local-6989586621681180957"><span class="annot"><span class="annottext">VarSet -&gt; (VarSet, [Id]) -&gt; ((VarSet, [Id]), a)
</span><a href="#local-6989586621681180957"><span class="hs-identifier hs-var">m</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681180956"><span class="annot"><span class="annottext">&gt;&gt;= :: forall a b. DFFV a -&gt; (a -&gt; DFFV b) -&gt; DFFV b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var hs-var hs-var hs-var">&gt;&gt;=</span></a></span></span><span> </span><span id="local-6989586621681180955"><span class="annot"><span class="annottext">a -&gt; DFFV b
</span><a href="#local-6989586621681180955"><span class="hs-identifier hs-var">k</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(VarSet -&gt; (VarSet, [Id]) -&gt; ((VarSet, [Id]), b)) -&gt; DFFV b
forall a.
(VarSet -&gt; (VarSet, [Id]) -&gt; ((VarSet, [Id]), a)) -&gt; DFFV a
</span><a href="GHC.Iface.Tidy.html#DFFV"><span class="hs-identifier hs-var">DFFV</span></a></span><span> </span><span class="annot"><span class="annottext">((VarSet -&gt; (VarSet, [Id]) -&gt; ((VarSet, [Id]), b)) -&gt; DFFV b)
-&gt; (VarSet -&gt; (VarSet, [Id]) -&gt; ((VarSet, [Id]), b)) -&gt; DFFV b
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681180954"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681180954"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621681180953"><span class="annot"><span class="annottext">(VarSet, [Id])
</span><a href="#local-6989586621681180953"><span class="hs-identifier hs-var">st</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-785"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; (VarSet, [Id]) -&gt; ((VarSet, [Id]), a)
</span><a href="#local-6989586621681180957"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681180954"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">(VarSet, [Id])
</span><a href="#local-6989586621681180953"><span class="hs-identifier hs-var">st</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-786"></span><span>       </span><span class="hs-special">(</span><span id="local-6989586621681180952"><span class="annot"><span class="annottext">(VarSet, [Id])
</span><a href="#local-6989586621681180952"><span class="hs-identifier hs-var">st'</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681180951"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681180951"><span class="hs-identifier hs-var">a</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">a -&gt; DFFV b
</span><a href="#local-6989586621681180955"><span class="hs-identifier hs-var">k</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681180951"><span class="hs-identifier hs-var">a</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-787"></span><span>                     </span><span class="annot"><a href="GHC.Iface.Tidy.html#DFFV"><span class="hs-identifier hs-type">DFFV</span></a></span><span> </span><span id="local-6989586621681180950"><span class="annot"><span class="annottext">VarSet -&gt; (VarSet, [Id]) -&gt; ((VarSet, [Id]), b)
</span><a href="#local-6989586621681180950"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; (VarSet, [Id]) -&gt; ((VarSet, [Id]), b)
</span><a href="#local-6989586621681180950"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681180954"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">(VarSet, [Id])
</span><a href="#local-6989586621681180952"><span class="hs-identifier hs-var">st'</span></a></span><span>
</span><span id="line-788"></span><span>
</span><span id="line-789"></span><span id="local-6989586621681181453"><span class="annot"><a href="GHC.Iface.Tidy.html#extendScope"><span class="hs-identifier hs-type">extendScope</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Iface.Tidy.html#DFFV"><span class="hs-identifier hs-type">DFFV</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681181453"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Iface.Tidy.html#DFFV"><span class="hs-identifier hs-type">DFFV</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681181453"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-790"></span><span id="extendScope"><span class="annot"><span class="annottext">extendScope :: forall a. Id -&gt; DFFV a -&gt; DFFV a
</span><a href="GHC.Iface.Tidy.html#extendScope"><span class="hs-identifier hs-var hs-var">extendScope</span></a></span></span><span> </span><span id="local-6989586621681180948"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180948"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Iface.Tidy.html#DFFV"><span class="hs-identifier hs-type">DFFV</span></a></span><span> </span><span id="local-6989586621681180947"><span class="annot"><span class="annottext">VarSet -&gt; (VarSet, [Id]) -&gt; ((VarSet, [Id]), a)
</span><a href="#local-6989586621681180947"><span class="hs-identifier hs-var">f</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(VarSet -&gt; (VarSet, [Id]) -&gt; ((VarSet, [Id]), a)) -&gt; DFFV a
forall a.
(VarSet -&gt; (VarSet, [Id]) -&gt; ((VarSet, [Id]), a)) -&gt; DFFV a
</span><a href="GHC.Iface.Tidy.html#DFFV"><span class="hs-identifier hs-var">DFFV</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681180946"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681180946"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621681180945"><span class="annot"><span class="annottext">(VarSet, [Id])
</span><a href="#local-6989586621681180945"><span class="hs-identifier hs-var">st</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; (VarSet, [Id]) -&gt; ((VarSet, [Id]), a)
</span><a href="#local-6989586621681180947"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet -&gt; Id -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#extendVarSet"><span class="hs-identifier hs-var">extendVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681180946"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180948"><span class="hs-identifier hs-var">v</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(VarSet, [Id])
</span><a href="#local-6989586621681180945"><span class="hs-identifier hs-var">st</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-791"></span><span>
</span><span id="line-792"></span><span id="local-6989586621681181451"><span class="annot"><a href="GHC.Iface.Tidy.html#extendScopeList"><span class="hs-identifier hs-type">extendScopeList</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Iface.Tidy.html#DFFV"><span class="hs-identifier hs-type">DFFV</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681181451"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Iface.Tidy.html#DFFV"><span class="hs-identifier hs-type">DFFV</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681181451"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-793"></span><span id="extendScopeList"><span class="annot"><span class="annottext">extendScopeList :: forall a. [Id] -&gt; DFFV a -&gt; DFFV a
</span><a href="GHC.Iface.Tidy.html#extendScopeList"><span class="hs-identifier hs-var hs-var">extendScopeList</span></a></span></span><span> </span><span id="local-6989586621681180942"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681180942"><span class="hs-identifier hs-var">vs</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Iface.Tidy.html#DFFV"><span class="hs-identifier hs-type">DFFV</span></a></span><span> </span><span id="local-6989586621681180941"><span class="annot"><span class="annottext">VarSet -&gt; (VarSet, [Id]) -&gt; ((VarSet, [Id]), a)
</span><a href="#local-6989586621681180941"><span class="hs-identifier hs-var">f</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(VarSet -&gt; (VarSet, [Id]) -&gt; ((VarSet, [Id]), a)) -&gt; DFFV a
forall a.
(VarSet -&gt; (VarSet, [Id]) -&gt; ((VarSet, [Id]), a)) -&gt; DFFV a
</span><a href="GHC.Iface.Tidy.html#DFFV"><span class="hs-identifier hs-var">DFFV</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681180940"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681180940"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621681180939"><span class="annot"><span class="annottext">(VarSet, [Id])
</span><a href="#local-6989586621681180939"><span class="hs-identifier hs-var">st</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; (VarSet, [Id]) -&gt; ((VarSet, [Id]), a)
</span><a href="#local-6989586621681180941"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet -&gt; [Id] -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#extendVarSetList"><span class="hs-identifier hs-var">extendVarSetList</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681180940"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681180942"><span class="hs-identifier hs-var">vs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(VarSet, [Id])
</span><a href="#local-6989586621681180939"><span class="hs-identifier hs-var">st</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-794"></span><span>
</span><span id="line-795"></span><span class="annot"><a href="GHC.Iface.Tidy.html#insert"><span class="hs-identifier hs-type">insert</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Iface.Tidy.html#DFFV"><span class="hs-identifier hs-type">DFFV</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-796"></span><span id="insert"><span class="annot"><span class="annottext">insert :: Id -&gt; DFFV ()
</span><a href="GHC.Iface.Tidy.html#insert"><span class="hs-identifier hs-var hs-var">insert</span></a></span></span><span> </span><span id="local-6989586621681180936"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180936"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(VarSet -&gt; (VarSet, [Id]) -&gt; ((VarSet, [Id]), ())) -&gt; DFFV ()
forall a.
(VarSet -&gt; (VarSet, [Id]) -&gt; ((VarSet, [Id]), a)) -&gt; DFFV a
</span><a href="GHC.Iface.Tidy.html#DFFV"><span class="hs-identifier hs-var">DFFV</span></a></span><span> </span><span class="annot"><span class="annottext">((VarSet -&gt; (VarSet, [Id]) -&gt; ((VarSet, [Id]), ())) -&gt; DFFV ())
-&gt; (VarSet -&gt; (VarSet, [Id]) -&gt; ((VarSet, [Id]), ())) -&gt; DFFV ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621681180935"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681180935"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681180934"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681180934"><span class="hs-identifier hs-var">set</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681180933"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681180933"><span class="hs-identifier hs-var">ids</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-797"></span><span>           </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681180932"><span class="annot"><span class="annottext">keep_me :: Bool
</span><a href="#local-6989586621681180932"><span class="hs-identifier hs-var hs-var">keep_me</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Var.html#isLocalId"><span class="hs-identifier hs-var">isLocalId</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180936"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span>
</span><span id="line-798"></span><span>                         </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180936"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#elemVarSet"><span class="hs-operator hs-var">`elemVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681180935"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span>
</span><span id="line-799"></span><span>                           </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180936"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#elemVarSet"><span class="hs-operator hs-var">`elemVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681180934"><span class="hs-identifier hs-var">set</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-800"></span><span>           </span><span class="hs-keyword">in</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681180932"><span class="hs-identifier hs-var">keep_me</span></a></span><span>
</span><span id="line-801"></span><span>              </span><span class="hs-keyword">then</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet -&gt; Id -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#extendVarSet"><span class="hs-identifier hs-var">extendVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681180934"><span class="hs-identifier hs-var">set</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180936"><span class="hs-identifier hs-var">v</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180936"><span class="hs-identifier hs-var">v</span></a></span><span class="annot"><span class="annottext">Id -&gt; [Id] -&gt; [Id]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681180933"><span class="hs-identifier hs-var">ids</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-802"></span><span>              </span><span class="hs-keyword">else</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681180934"><span class="hs-identifier hs-var">set</span></a></span><span class="hs-special">,</span><span>                </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681180933"><span class="hs-identifier hs-var">ids</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span>   </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-803"></span><span>
</span><span id="line-804"></span><span>
</span><span id="line-805"></span><span class="annot"><a href="GHC.Iface.Tidy.html#dffvExpr"><span class="hs-identifier hs-type">dffvExpr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Iface.Tidy.html#DFFV"><span class="hs-identifier hs-type">DFFV</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-806"></span><span id="dffvExpr"><span class="annot"><span class="annottext">dffvExpr :: Expr Id -&gt; DFFV ()
</span><a href="GHC.Iface.Tidy.html#dffvExpr"><span class="hs-identifier hs-var hs-var">dffvExpr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span> </span><span id="local-6989586621681180926"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180926"><span class="hs-identifier hs-var">v</span></a></span></span><span class="hs-special">)</span><span>              </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; DFFV ()
</span><a href="GHC.Iface.Tidy.html#insert"><span class="hs-identifier hs-var">insert</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180926"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-807"></span><span class="annot"><a href="GHC.Iface.Tidy.html#dffvExpr"><span class="hs-identifier hs-var">dffvExpr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#App"><span class="hs-identifier hs-type">App</span></a></span><span> </span><span id="local-6989586621681180924"><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180924"><span class="hs-identifier hs-var">e1</span></a></span></span><span> </span><span id="local-6989586621681180923"><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180923"><span class="hs-identifier hs-var">e2</span></a></span></span><span class="hs-special">)</span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Expr Id -&gt; DFFV ()
</span><a href="GHC.Iface.Tidy.html#dffvExpr"><span class="hs-identifier hs-var">dffvExpr</span></a></span><span> </span><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180924"><span class="hs-identifier hs-var">e1</span></a></span><span> </span><span class="annot"><span class="annottext">DFFV () -&gt; DFFV () -&gt; DFFV ()
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; m b -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E"><span class="hs-operator hs-var">&gt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Expr Id -&gt; DFFV ()
</span><a href="GHC.Iface.Tidy.html#dffvExpr"><span class="hs-identifier hs-var">dffvExpr</span></a></span><span> </span><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180923"><span class="hs-identifier hs-var">e2</span></a></span><span>
</span><span id="line-808"></span><span class="annot"><a href="GHC.Iface.Tidy.html#dffvExpr"><span class="hs-identifier hs-var">dffvExpr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Lam"><span class="hs-identifier hs-type">Lam</span></a></span><span> </span><span id="local-6989586621681180921"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180921"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span id="local-6989586621681180920"><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180920"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; DFFV () -&gt; DFFV ()
forall a. Id -&gt; DFFV a -&gt; DFFV a
</span><a href="GHC.Iface.Tidy.html#extendScope"><span class="hs-identifier hs-var">extendScope</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180921"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Expr Id -&gt; DFFV ()
</span><a href="GHC.Iface.Tidy.html#dffvExpr"><span class="hs-identifier hs-var">dffvExpr</span></a></span><span> </span><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180920"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-809"></span><span class="annot"><a href="GHC.Iface.Tidy.html#dffvExpr"><span class="hs-identifier hs-var">dffvExpr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Tick"><span class="hs-identifier hs-type">Tick</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Breakpoint"><span class="hs-identifier hs-type">Breakpoint</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681180917"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681180917"><span class="hs-identifier hs-var">ids</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681180916"><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180916"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Id -&gt; DFFV ()) -&gt; [Id] -&gt; DFFV ()
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Foldable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m ()
</span><a href="../../base/src/Data.Foldable.html#mapM_"><span class="hs-identifier hs-var">mapM_</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; DFFV ()
</span><a href="GHC.Iface.Tidy.html#insert"><span class="hs-identifier hs-var">insert</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681180917"><span class="hs-identifier hs-var">ids</span></a></span><span> </span><span class="annot"><span class="annottext">DFFV () -&gt; DFFV () -&gt; DFFV ()
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; m b -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E"><span class="hs-operator hs-var">&gt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Expr Id -&gt; DFFV ()
</span><a href="GHC.Iface.Tidy.html#dffvExpr"><span class="hs-identifier hs-var">dffvExpr</span></a></span><span> </span><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180916"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-810"></span><span class="annot"><a href="GHC.Iface.Tidy.html#dffvExpr"><span class="hs-identifier hs-var">dffvExpr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Tick"><span class="hs-identifier hs-type">Tick</span></a></span><span> </span><span id="local-6989586621681180914"><span class="annot"><span class="annottext">Tickish Id
</span><a href="#local-6989586621681180914"><span class="hs-identifier hs-var">_other</span></a></span></span><span> </span><span id="local-6989586621681180913"><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180913"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Expr Id -&gt; DFFV ()
</span><a href="GHC.Iface.Tidy.html#dffvExpr"><span class="hs-identifier hs-var">dffvExpr</span></a></span><span> </span><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180913"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-811"></span><span class="annot"><a href="GHC.Iface.Tidy.html#dffvExpr"><span class="hs-identifier hs-var">dffvExpr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Cast"><span class="hs-identifier hs-type">Cast</span></a></span><span> </span><span id="local-6989586621681180911"><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180911"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span class="annot"><span class="annottext">CoercionR
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Expr Id -&gt; DFFV ()
</span><a href="GHC.Iface.Tidy.html#dffvExpr"><span class="hs-identifier hs-var">dffvExpr</span></a></span><span> </span><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180911"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-812"></span><span class="annot"><a href="GHC.Iface.Tidy.html#dffvExpr"><span class="hs-identifier hs-var">dffvExpr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Let"><span class="hs-identifier hs-type">Let</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#NonRec"><span class="hs-identifier hs-type">NonRec</span></a></span><span> </span><span id="local-6989586621681180909"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180909"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621681180908"><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180908"><span class="hs-identifier hs-var">r</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681180907"><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180907"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Id, Expr Id) -&gt; DFFV ()
</span><a href="GHC.Iface.Tidy.html#dffvBind"><span class="hs-identifier hs-var">dffvBind</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180909"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180908"><span class="hs-identifier hs-var">r</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">DFFV () -&gt; DFFV () -&gt; DFFV ()
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; m b -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E"><span class="hs-operator hs-var">&gt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; DFFV () -&gt; DFFV ()
forall a. Id -&gt; DFFV a -&gt; DFFV a
</span><a href="GHC.Iface.Tidy.html#extendScope"><span class="hs-identifier hs-var">extendScope</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180909"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Expr Id -&gt; DFFV ()
</span><a href="GHC.Iface.Tidy.html#dffvExpr"><span class="hs-identifier hs-var">dffvExpr</span></a></span><span> </span><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180907"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-813"></span><span class="annot"><a href="GHC.Iface.Tidy.html#dffvExpr"><span class="hs-identifier hs-var">dffvExpr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Let"><span class="hs-identifier hs-type">Let</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Rec"><span class="hs-identifier hs-type">Rec</span></a></span><span> </span><span id="local-6989586621681180904"><span class="annot"><span class="annottext">[(Id, Expr Id)]
</span><a href="#local-6989586621681180904"><span class="hs-identifier hs-var">prs</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681180903"><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180903"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; DFFV () -&gt; DFFV ()
forall a. [Id] -&gt; DFFV a -&gt; DFFV a
</span><a href="GHC.Iface.Tidy.html#extendScopeList"><span class="hs-identifier hs-var">extendScopeList</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">((Id, Expr Id) -&gt; Id) -&gt; [(Id, Expr Id)] -&gt; [Id]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">(Id, Expr Id) -&gt; Id
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span> </span><span class="annot"><span class="annottext">[(Id, Expr Id)]
</span><a href="#local-6989586621681180904"><span class="hs-identifier hs-var">prs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(DFFV () -&gt; DFFV ()) -&gt; DFFV () -&gt; DFFV ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-814"></span><span>                                </span><span class="hs-special">(</span><span class="annot"><span class="annottext">((Id, Expr Id) -&gt; DFFV ()) -&gt; [(Id, Expr Id)] -&gt; DFFV ()
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Foldable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m ()
</span><a href="../../base/src/Data.Foldable.html#mapM_"><span class="hs-identifier hs-var">mapM_</span></a></span><span> </span><span class="annot"><span class="annottext">(Id, Expr Id) -&gt; DFFV ()
</span><a href="GHC.Iface.Tidy.html#dffvBind"><span class="hs-identifier hs-var">dffvBind</span></a></span><span> </span><span class="annot"><span class="annottext">[(Id, Expr Id)]
</span><a href="#local-6989586621681180904"><span class="hs-identifier hs-var">prs</span></a></span><span> </span><span class="annot"><span class="annottext">DFFV () -&gt; DFFV () -&gt; DFFV ()
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; m b -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E"><span class="hs-operator hs-var">&gt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Expr Id -&gt; DFFV ()
</span><a href="GHC.Iface.Tidy.html#dffvExpr"><span class="hs-identifier hs-var">dffvExpr</span></a></span><span> </span><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180903"><span class="hs-identifier hs-var">e</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-815"></span><span class="annot"><a href="GHC.Iface.Tidy.html#dffvExpr"><span class="hs-identifier hs-var">dffvExpr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Case"><span class="hs-identifier hs-type">Case</span></a></span><span> </span><span id="local-6989586621681180901"><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180901"><span class="hs-identifier hs-var">e</span></a></span></span><span> </span><span id="local-6989586621681180900"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180900"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681180899"><span class="annot"><span class="annottext">[Alt Id]
</span><a href="#local-6989586621681180899"><span class="hs-keyword hs-var">as</span></a></span></span><span class="hs-special">)</span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Expr Id -&gt; DFFV ()
</span><a href="GHC.Iface.Tidy.html#dffvExpr"><span class="hs-identifier hs-var">dffvExpr</span></a></span><span> </span><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180901"><span class="hs-identifier hs-var">e</span></a></span><span> </span><span class="annot"><span class="annottext">DFFV () -&gt; DFFV () -&gt; DFFV ()
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; m b -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E"><span class="hs-operator hs-var">&gt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; DFFV () -&gt; DFFV ()
forall a. Id -&gt; DFFV a -&gt; DFFV a
</span><a href="GHC.Iface.Tidy.html#extendScope"><span class="hs-identifier hs-var">extendScope</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180900"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Alt Id -&gt; DFFV ()) -&gt; [Alt Id] -&gt; DFFV ()
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Foldable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m ()
</span><a href="../../base/src/Data.Foldable.html#mapM_"><span class="hs-identifier hs-var">mapM_</span></a></span><span> </span><span class="annot"><span class="annottext">Alt Id -&gt; DFFV ()
forall t. (t, [Id], Expr Id) -&gt; DFFV ()
</span><a href="GHC.Iface.Tidy.html#dffvAlt"><span class="hs-identifier hs-var">dffvAlt</span></a></span><span> </span><span class="annot"><span class="annottext">[Alt Id]
</span><a href="#local-6989586621681180899"><span class="hs-keyword hs-var">as</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-816"></span><span class="annot"><a href="GHC.Iface.Tidy.html#dffvExpr"><span class="hs-identifier hs-var">dffvExpr</span></a></span><span> </span><span id="local-6989586621681180897"><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180897"><span class="hs-identifier hs-var">_other</span></a></span></span><span>               </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">() -&gt; DFFV ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-817"></span><span>
</span><span id="line-818"></span><span id="local-6989586621681181442"><span class="annot"><a href="GHC.Iface.Tidy.html#dffvAlt"><span class="hs-identifier hs-type">dffvAlt</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621681181442"><span class="hs-identifier hs-type">t</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Var"><span class="hs-identifier hs-type">Var</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Iface.Tidy.html#DFFV"><span class="hs-identifier hs-type">DFFV</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span></span><span>
</span><span id="line-819"></span><span id="dffvAlt"><span class="annot"><span class="annottext">dffvAlt :: forall t. (t, [Id], Expr Id) -&gt; DFFV ()
</span><a href="GHC.Iface.Tidy.html#dffvAlt"><span class="hs-identifier hs-var hs-var">dffvAlt</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">t
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span id="local-6989586621681180896"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681180896"><span class="hs-identifier hs-var">xs</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681180895"><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180895"><span class="hs-identifier hs-var">r</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; DFFV () -&gt; DFFV ()
forall a. [Id] -&gt; DFFV a -&gt; DFFV a
</span><a href="GHC.Iface.Tidy.html#extendScopeList"><span class="hs-identifier hs-var">extendScopeList</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681180896"><span class="hs-identifier hs-var">xs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Expr Id -&gt; DFFV ()
</span><a href="GHC.Iface.Tidy.html#dffvExpr"><span class="hs-identifier hs-var">dffvExpr</span></a></span><span> </span><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180895"><span class="hs-identifier hs-var">r</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-820"></span><span>
</span><span id="line-821"></span><span class="annot"><a href="GHC.Iface.Tidy.html#dffvBind"><span class="hs-identifier hs-type">dffvBind</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Iface.Tidy.html#DFFV"><span class="hs-identifier hs-type">DFFV</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-822"></span><span id="dffvBind"><span class="annot"><span class="annottext">dffvBind :: (Id, Expr Id) -&gt; DFFV ()
</span><a href="GHC.Iface.Tidy.html#dffvBind"><span class="hs-identifier hs-var hs-var">dffvBind</span></a></span></span><span class="hs-special">(</span><span id="local-6989586621681180894"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180894"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681180893"><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180893"><span class="hs-identifier hs-var">r</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-823"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Var.html#isId"><span class="hs-identifier hs-var">isId</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180894"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Expr Id -&gt; DFFV ()
</span><a href="GHC.Iface.Tidy.html#dffvExpr"><span class="hs-identifier hs-var">dffvExpr</span></a></span><span> </span><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180893"><span class="hs-identifier hs-var">r</span></a></span><span>
</span><span id="line-824"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Id -&gt; DFFV ()
</span><a href="GHC.Iface.Tidy.html#dffvLetBndr"><span class="hs-identifier hs-var">dffvLetBndr</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180894"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">DFFV () -&gt; DFFV () -&gt; DFFV ()
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; m b -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E"><span class="hs-operator hs-var">&gt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Expr Id -&gt; DFFV ()
</span><a href="GHC.Iface.Tidy.html#dffvExpr"><span class="hs-identifier hs-var">dffvExpr</span></a></span><span> </span><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180893"><span class="hs-identifier hs-var">r</span></a></span><span>
</span><span id="line-825"></span><span>                </span><span class="hs-comment">-- Pass False because we are doing the RHS right here</span><span>
</span><span id="line-826"></span><span>                </span><span class="hs-comment">-- If you say True you'll get *exponential* behaviour!</span><span>
</span><span id="line-827"></span><span>
</span><span id="line-828"></span><span class="annot"><a href="GHC.Iface.Tidy.html#dffvLetBndr"><span class="hs-identifier hs-type">dffvLetBndr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Iface.Tidy.html#DFFV"><span class="hs-identifier hs-type">DFFV</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-829"></span><span class="hs-comment">-- Gather the free vars of the RULES and unfolding of a binder</span><span>
</span><span id="line-830"></span><span class="hs-comment">-- We always get the free vars of a *stable* unfolding, but</span><span>
</span><span id="line-831"></span><span class="hs-comment">-- for a *vanilla* one (InlineRhs), the flag controls what happens:</span><span>
</span><span id="line-832"></span><span class="hs-comment">--   True &lt;=&gt; get fvs of even a *vanilla* unfolding</span><span>
</span><span id="line-833"></span><span class="hs-comment">--   False &lt;=&gt; ignore an InlineRhs</span><span>
</span><span id="line-834"></span><span class="hs-comment">-- For nested bindings (call from dffvBind) we always say &quot;False&quot; because</span><span>
</span><span id="line-835"></span><span class="hs-comment">--       we are taking the fvs of the RHS anyway</span><span>
</span><span id="line-836"></span><span class="hs-comment">-- For top-level bindings (call from addExternal, via bndrFvsInOrder)</span><span>
</span><span id="line-837"></span><span class="hs-comment">--       we say &quot;True&quot; if we are exposing that unfolding</span><span>
</span><span id="line-838"></span><span id="dffvLetBndr"><span class="annot"><span class="annottext">dffvLetBndr :: Bool -&gt; Id -&gt; DFFV ()
</span><a href="GHC.Iface.Tidy.html#dffvLetBndr"><span class="hs-identifier hs-var hs-var">dffvLetBndr</span></a></span></span><span> </span><span id="local-6989586621681180891"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681180891"><span class="hs-identifier hs-var">vanilla_unfold</span></a></span></span><span> </span><span id="local-6989586621681180890"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180890"><span class="hs-identifier hs-var">id</span></a></span></span><span>
</span><span id="line-839"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">Unfolding -&gt; DFFV ()
</span><a href="#local-6989586621681180889"><span class="hs-identifier hs-var">go_unf</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IdInfo -&gt; Unfolding
</span><a href="GHC.Types.Id.Info.html#unfoldingInfo"><span class="hs-identifier hs-var hs-var">unfoldingInfo</span></a></span><span> </span><span class="annot"><span class="annottext">IdInfo
</span><a href="#local-6989586621681180888"><span class="hs-identifier hs-var">idinfo</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-840"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(CoreRule -&gt; DFFV ()) -&gt; [CoreRule] -&gt; DFFV ()
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Foldable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m ()
</span><a href="../../base/src/Data.Foldable.html#mapM_"><span class="hs-identifier hs-var">mapM_</span></a></span><span> </span><span class="annot"><span class="annottext">CoreRule -&gt; DFFV ()
</span><a href="#local-6989586621681180887"><span class="hs-identifier hs-var">go_rule</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">RuleInfo -&gt; [CoreRule]
</span><a href="GHC.Types.Id.Info.html#ruleInfoRules"><span class="hs-identifier hs-var">ruleInfoRules</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IdInfo -&gt; RuleInfo
</span><a href="GHC.Types.Id.Info.html#ruleInfo"><span class="hs-identifier hs-var hs-var">ruleInfo</span></a></span><span> </span><span class="annot"><span class="annottext">IdInfo
</span><a href="#local-6989586621681180888"><span class="hs-identifier hs-var">idinfo</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-841"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-842"></span><span>    </span><span id="local-6989586621681180888"><span class="annot"><span class="annottext">idinfo :: IdInfo
</span><a href="#local-6989586621681180888"><span class="hs-identifier hs-var hs-var">idinfo</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Id -&gt; IdInfo
Id -&gt; IdInfo
</span><a href="GHC.Types.Var.html#idInfo"><span class="hs-identifier hs-var">idInfo</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180890"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-843"></span><span>
</span><span id="line-844"></span><span>    </span><span id="local-6989586621681180889"><span class="annot"><span class="annottext">go_unf :: Unfolding -&gt; DFFV ()
</span><a href="#local-6989586621681180889"><span class="hs-identifier hs-var hs-var">go_unf</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#CoreUnfolding"><span class="hs-identifier hs-type">CoreUnfolding</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">uf_tmpl :: Unfolding -&gt; Expr Id
</span><a href="GHC.Core.html#uf_tmpl"><span class="hs-identifier hs-var">uf_tmpl</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681180878"><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180878"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">uf_src :: Unfolding -&gt; UnfoldingSource
</span><a href="GHC.Core.html#uf_src"><span class="hs-identifier hs-var">uf_src</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681180877"><span class="annot"><span class="annottext">UnfoldingSource
</span><a href="#local-6989586621681180877"><span class="hs-identifier hs-var">src</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-845"></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">UnfoldingSource
</span><a href="#local-6989586621681180877"><span class="hs-identifier hs-var">src</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-846"></span><span>           </span><span class="annot"><span class="annottext">UnfoldingSource
</span><a href="GHC.Core.html#InlineRhs"><span class="hs-identifier hs-var">InlineRhs</span></a></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681180891"><span class="hs-identifier hs-var">vanilla_unfold</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Expr Id -&gt; DFFV ()
</span><a href="GHC.Iface.Tidy.html#dffvExpr"><span class="hs-identifier hs-var">dffvExpr</span></a></span><span> </span><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180878"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-847"></span><span>                     </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">() -&gt; DFFV ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-848"></span><span>           </span><span class="annot"><span class="annottext">UnfoldingSource
</span><span class="hs-identifier">_</span></span><span>                          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Expr Id -&gt; DFFV ()
</span><a href="GHC.Iface.Tidy.html#dffvExpr"><span class="hs-identifier hs-var">dffvExpr</span></a></span><span> </span><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180878"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-849"></span><span>
</span><span id="line-850"></span><span>    </span><span class="annot"><a href="#local-6989586621681180889"><span class="hs-identifier hs-var">go_unf</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#DFunUnfolding"><span class="hs-identifier hs-type">DFunUnfolding</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">df_bndrs :: Unfolding -&gt; [Id]
</span><a href="GHC.Core.html#df_bndrs"><span class="hs-identifier hs-var">df_bndrs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681180874"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681180874"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">df_args :: Unfolding -&gt; [Expr Id]
</span><a href="GHC.Core.html#df_args"><span class="hs-identifier hs-var">df_args</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681180872"><span class="annot"><span class="annottext">[Expr Id]
</span><a href="#local-6989586621681180872"><span class="hs-identifier hs-var">args</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-851"></span><span>             </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; DFFV () -&gt; DFFV ()
forall a. [Id] -&gt; DFFV a -&gt; DFFV a
</span><a href="GHC.Iface.Tidy.html#extendScopeList"><span class="hs-identifier hs-var">extendScopeList</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681180874"><span class="hs-identifier hs-var">bndrs</span></a></span><span> </span><span class="annot"><span class="annottext">(DFFV () -&gt; DFFV ()) -&gt; DFFV () -&gt; DFFV ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(Expr Id -&gt; DFFV ()) -&gt; [Expr Id] -&gt; DFFV ()
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Foldable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m ()
</span><a href="../../base/src/Data.Foldable.html#mapM_"><span class="hs-identifier hs-var">mapM_</span></a></span><span> </span><span class="annot"><span class="annottext">Expr Id -&gt; DFFV ()
</span><a href="GHC.Iface.Tidy.html#dffvExpr"><span class="hs-identifier hs-var">dffvExpr</span></a></span><span> </span><span class="annot"><span class="annottext">[Expr Id]
</span><a href="#local-6989586621681180872"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-852"></span><span>    </span><span class="annot"><a href="#local-6989586621681180889"><span class="hs-identifier hs-var">go_unf</span></a></span><span> </span><span class="annot"><span class="annottext">Unfolding
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">() -&gt; DFFV ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-853"></span><span>
</span><span id="line-854"></span><span>    </span><span id="local-6989586621681180887"><span class="annot"><span class="annottext">go_rule :: CoreRule -&gt; DFFV ()
</span><a href="#local-6989586621681180887"><span class="hs-identifier hs-var hs-var">go_rule</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#BuiltinRule"><span class="hs-identifier hs-type">BuiltinRule</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">() -&gt; DFFV ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-855"></span><span>    </span><span class="annot"><a href="#local-6989586621681180887"><span class="hs-identifier hs-var">go_rule</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Rule"><span class="hs-identifier hs-type">Rule</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ru_bndrs :: CoreRule -&gt; [Id]
</span><a href="GHC.Core.html#ru_bndrs"><span class="hs-identifier hs-var">ru_bndrs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681180867"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681180867"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ru_rhs :: CoreRule -&gt; Expr Id
</span><a href="GHC.Core.html#ru_rhs"><span class="hs-identifier hs-var">ru_rhs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681180865"><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180865"><span class="hs-identifier hs-var">rhs</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-856"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; DFFV () -&gt; DFFV ()
forall a. [Id] -&gt; DFFV a -&gt; DFFV a
</span><a href="GHC.Iface.Tidy.html#extendScopeList"><span class="hs-identifier hs-var">extendScopeList</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681180867"><span class="hs-identifier hs-var">bndrs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Expr Id -&gt; DFFV ()
</span><a href="GHC.Iface.Tidy.html#dffvExpr"><span class="hs-identifier hs-var">dffvExpr</span></a></span><span> </span><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180865"><span class="hs-identifier hs-var">rhs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-857"></span><span>
</span><span id="line-858"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
               findExternalRules
*                                                                      *
************************************************************************

Note [Finding external rules]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The complete rules are gotten by combining
   a) local rules for imported Ids
   b) rules embedded in the top-level Ids

There are two complications:
  * Note [Which rules to expose]
  * Note [Trimming auto-rules]

Note [Which rules to expose]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The function 'expose_rule' filters out rules that mention, on the LHS,
Ids that aren't externally visible; these rules can't fire in a client
module.

The externally-visible binders are computed (by chooseExternalIds)
assuming that all orphan rules are externalised (see init_ext_ids in
function 'search'). So in fact it's a bit conservative and we may
export more than we need.  (It's a sort of mutual recursion.)

Note [Trimming auto-rules]
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Second, with auto-specialisation we may specialise local or imported
dfuns or INLINE functions, and then later inline them.  That may leave
behind something like
   RULE &quot;foo&quot; forall d. f @ Int d = f_spec
where f is either local or imported, and there is no remaining
reference to f_spec except from the RULE.

Now that RULE *might* be useful to an importing module, but that is
purely speculative, and meanwhile the code is taking up space and
codegen time.  I found that binary sizes jumped by 6-10% when I
started to specialise INLINE functions (again, Note [Inline
specialisations] in GHC.Core.Opt.Specialise).

So it seems better to drop the binding for f_spec, and the rule
itself, if the auto-generated rule is the *only* reason that it is
being kept alive.

(The RULE still might have been useful in the past; that is, it was
the right thing to have generated it in the first place.  See Note
[Inline specialisations] in GHC.Core.Opt.Specialise. But now it has
served its purpose, and can be discarded.)

So findExternalRules does this:
  * Remove all bindings that are kept alive *only* by isAutoRule rules
      (this is done in trim_binds)
  * Remove all auto rules that mention bindings that have been removed
      (this is done by filtering by keep_rule)

NB: if a binding is kept alive for some *other* reason (e.g. f_spec is
called in the final code), we keep the rule too.

This stuff is the only reason for the ru_auto field in a Rule.
-}</span><span>
</span><span id="line-921"></span><span>
</span><span id="line-922"></span><span class="annot"><a href="GHC.Iface.Tidy.html#findExternalRules"><span class="hs-identifier hs-type">findExternalRules</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>       </span><span class="hs-comment">-- Omit pragmas</span><span>
</span><span id="line-923"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreBind"><span class="hs-identifier hs-type">CoreBind</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-924"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreRule"><span class="hs-identifier hs-type">CoreRule</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-comment">-- Local rules for imported fns</span><span>
</span><span id="line-925"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Iface.Tidy.html#UnfoldEnv"><span class="hs-identifier hs-type">UnfoldEnv</span></a></span><span>  </span><span class="hs-comment">-- Ids that are exported, so we need their rules</span><span>
</span><span id="line-926"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreBind"><span class="hs-identifier hs-type">CoreBind</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreRule"><span class="hs-identifier hs-type">CoreRule</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-927"></span><span class="hs-comment">-- See Note [Finding external rules]</span><span>
</span><span id="line-928"></span><span id="findExternalRules"><span class="annot"><span class="annottext">findExternalRules :: Bool
-&gt; CoreProgram
-&gt; [CoreRule]
-&gt; UnfoldEnv
-&gt; (CoreProgram, [CoreRule])
</span><a href="GHC.Iface.Tidy.html#findExternalRules"><span class="hs-identifier hs-var hs-var">findExternalRules</span></a></span></span><span> </span><span id="local-6989586621681180864"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681180864"><span class="hs-identifier hs-var">omit_prags</span></a></span></span><span> </span><span id="local-6989586621681180863"><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621681180863"><span class="hs-identifier hs-var">binds</span></a></span></span><span> </span><span id="local-6989586621681180862"><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621681180862"><span class="hs-identifier hs-var">imp_id_rules</span></a></span></span><span> </span><span id="local-6989586621681180861"><span class="annot"><span class="annottext">UnfoldEnv
</span><a href="#local-6989586621681180861"><span class="hs-identifier hs-var">unfold_env</span></a></span></span><span>
</span><span id="line-929"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621681180860"><span class="hs-identifier hs-var">trimmed_binds</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">(CoreRule -&gt; Bool) -&gt; [CoreRule] -&gt; [CoreRule]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="annot"><span class="annottext">CoreRule -&gt; Bool
</span><a href="#local-6989586621681180859"><span class="hs-identifier hs-var">keep_rule</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621681180858"><span class="hs-identifier hs-var">all_rules</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-930"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-931"></span><span>    </span><span id="local-6989586621681180857"><span class="annot"><span class="annottext">imp_rules :: [CoreRule]
</span><a href="#local-6989586621681180857"><span class="hs-identifier hs-var hs-var">imp_rules</span></a></span></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CoreRule -&gt; Bool) -&gt; [CoreRule] -&gt; [CoreRule]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="annot"><span class="annottext">CoreRule -&gt; Bool
</span><a href="#local-6989586621681180856"><span class="hs-identifier hs-var">expose_rule</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621681180862"><span class="hs-identifier hs-var">imp_id_rules</span></a></span><span>
</span><span id="line-932"></span><span>    </span><span id="local-6989586621681180855"><span class="annot"><span class="annottext">imp_user_rule_fvs :: VarSet
</span><a href="#local-6989586621681180855"><span class="hs-identifier hs-var hs-var">imp_user_rule_fvs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CoreRule -&gt; VarSet) -&gt; [CoreRule] -&gt; VarSet
forall a. (a -&gt; VarSet) -&gt; [a] -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#mapUnionVarSet"><span class="hs-identifier hs-var">mapUnionVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">CoreRule -&gt; VarSet
</span><a href="#local-6989586621681180854"><span class="hs-identifier hs-var">user_rule_rhs_fvs</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621681180857"><span class="hs-identifier hs-var">imp_rules</span></a></span><span>
</span><span id="line-933"></span><span>
</span><span id="line-934"></span><span>    </span><span id="local-6989586621681180854"><span class="annot"><span class="annottext">user_rule_rhs_fvs :: CoreRule -&gt; VarSet
</span><a href="#local-6989586621681180854"><span class="hs-identifier hs-var hs-var">user_rule_rhs_fvs</span></a></span></span><span> </span><span id="local-6989586621681180853"><span class="annot"><span class="annottext">CoreRule
</span><a href="#local-6989586621681180853"><span class="hs-identifier hs-var">rule</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">CoreRule -&gt; Bool
</span><a href="GHC.Core.html#isAutoRule"><span class="hs-identifier hs-var">isAutoRule</span></a></span><span> </span><span class="annot"><span class="annottext">CoreRule
</span><a href="#local-6989586621681180853"><span class="hs-identifier hs-var">rule</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="GHC.Types.Var.Set.html#emptyVarSet"><span class="hs-identifier hs-var">emptyVarSet</span></a></span><span>
</span><span id="line-935"></span><span>                           </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreRule -&gt; VarSet
</span><a href="GHC.Core.FVs.html#ruleRhsFreeVars"><span class="hs-identifier hs-var">ruleRhsFreeVars</span></a></span><span> </span><span class="annot"><span class="annottext">CoreRule
</span><a href="#local-6989586621681180853"><span class="hs-identifier hs-var">rule</span></a></span><span>
</span><span id="line-936"></span><span>
</span><span id="line-937"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621681180860"><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621681180860"><span class="hs-identifier hs-var">trimmed_binds</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681180851"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681180851"><span class="hs-identifier hs-var">local_bndrs</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681180858"><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621681180858"><span class="hs-identifier hs-var">all_rules</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreProgram -&gt; (CoreProgram, VarSet, VarSet, [CoreRule])
</span><a href="#local-6989586621681180850"><span class="hs-identifier hs-var">trim_binds</span></a></span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621681180863"><span class="hs-identifier hs-var">binds</span></a></span><span>
</span><span id="line-938"></span><span>
</span><span id="line-939"></span><span>    </span><span id="local-6989586621681180859"><span class="annot"><span class="annottext">keep_rule :: CoreRule -&gt; Bool
</span><a href="#local-6989586621681180859"><span class="hs-identifier hs-var hs-var">keep_rule</span></a></span></span><span> </span><span id="local-6989586621681180849"><span class="annot"><span class="annottext">CoreRule
</span><a href="#local-6989586621681180849"><span class="hs-identifier hs-var">rule</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreRule -&gt; VarSet
</span><a href="GHC.Core.FVs.html#ruleFreeVars"><span class="hs-identifier hs-var">ruleFreeVars</span></a></span><span> </span><span class="annot"><span class="annottext">CoreRule
</span><a href="#local-6989586621681180849"><span class="hs-identifier hs-var">rule</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#subVarSet"><span class="hs-operator hs-var">`subVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681180851"><span class="hs-identifier hs-var">local_bndrs</span></a></span><span>
</span><span id="line-940"></span><span>        </span><span class="hs-comment">-- Remove rules that make no sense, because they mention a</span><span>
</span><span id="line-941"></span><span>        </span><span class="hs-comment">-- local binder (on LHS or RHS) that we have now discarded.</span><span>
</span><span id="line-942"></span><span>        </span><span class="hs-comment">-- (NB: ruleFreeVars only includes LocalIds)</span><span>
</span><span id="line-943"></span><span>        </span><span class="hs-comment">--</span><span>
</span><span id="line-944"></span><span>        </span><span class="hs-comment">-- LHS: we have already filtered out rules that mention internal Ids</span><span>
</span><span id="line-945"></span><span>        </span><span class="hs-comment">--     on LHS but that isn't enough because we might have by now</span><span>
</span><span id="line-946"></span><span>        </span><span class="hs-comment">--     discarded a binding with an external Id. (How?</span><span>
</span><span id="line-947"></span><span>        </span><span class="hs-comment">--     chooseExternalIds is a bit conservative.)</span><span>
</span><span id="line-948"></span><span>        </span><span class="hs-comment">--</span><span>
</span><span id="line-949"></span><span>        </span><span class="hs-comment">-- RHS: the auto rules that might mention a binder that has</span><span>
</span><span id="line-950"></span><span>        </span><span class="hs-comment">--      been discarded; see Note [Trimming auto-rules]</span><span>
</span><span id="line-951"></span><span>
</span><span id="line-952"></span><span>    </span><span id="local-6989586621681180856"><span class="annot"><span class="annottext">expose_rule :: CoreRule -&gt; Bool
</span><a href="#local-6989586621681180856"><span class="hs-identifier hs-var hs-var">expose_rule</span></a></span></span><span> </span><span id="local-6989586621681180845"><span class="annot"><span class="annottext">CoreRule
</span><a href="#local-6989586621681180845"><span class="hs-identifier hs-var">rule</span></a></span></span><span>
</span><span id="line-953"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681180864"><span class="hs-identifier hs-var">omit_prags</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-954"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Id -&gt; Bool) -&gt; [Id] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#all"><span class="hs-identifier hs-var">all</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="#local-6989586621681180843"><span class="hs-identifier hs-var">is_external_id</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoreRule -&gt; [Id]
</span><a href="GHC.Core.FVs.html#ruleLhsFreeIdsList"><span class="hs-identifier hs-var">ruleLhsFreeIdsList</span></a></span><span> </span><span class="annot"><span class="annottext">CoreRule
</span><a href="#local-6989586621681180845"><span class="hs-identifier hs-var">rule</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-955"></span><span>                </span><span class="hs-comment">-- Don't expose a rule whose LHS mentions a locally-defined</span><span>
</span><span id="line-956"></span><span>                </span><span class="hs-comment">-- Id that is completely internal (i.e. not visible to an</span><span>
</span><span id="line-957"></span><span>                </span><span class="hs-comment">-- importing module).  NB: ruleLhsFreeIds only returns LocalIds.</span><span>
</span><span id="line-958"></span><span>                </span><span class="hs-comment">-- See Note [Which rules to expose]</span><span>
</span><span id="line-959"></span><span>
</span><span id="line-960"></span><span>    </span><span id="local-6989586621681180843"><span class="annot"><span class="annottext">is_external_id :: Id -&gt; Bool
</span><a href="#local-6989586621681180843"><span class="hs-identifier hs-var hs-var">is_external_id</span></a></span></span><span> </span><span id="local-6989586621681180841"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180841"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">UnfoldEnv -&gt; Id -&gt; Maybe (Name, Bool)
forall a. VarEnv a -&gt; Id -&gt; Maybe a
</span><a href="GHC.Types.Var.Env.html#lookupVarEnv"><span class="hs-identifier hs-var">lookupVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">UnfoldEnv
</span><a href="#local-6989586621681180861"><span class="hs-identifier hs-var">unfold_env</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180841"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-961"></span><span>                          </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681180839"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681180839"><span class="hs-identifier hs-var">name</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Name -&gt; Bool
</span><a href="GHC.Types.Name.html#isExternalName"><span class="hs-identifier hs-var">isExternalName</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681180839"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-962"></span><span>                          </span><span class="annot"><span class="annottext">Maybe (Name, Bool)
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-963"></span><span>
</span><span id="line-964"></span><span>    </span><span class="annot"><a href="#local-6989586621681180850"><span class="hs-identifier hs-type">trim_binds</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreBind"><span class="hs-identifier hs-type">CoreBind</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-965"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreBind"><span class="hs-identifier hs-type">CoreBind</span></a></span><span class="hs-special">]</span><span>   </span><span class="hs-comment">-- Trimmed bindings</span><span>
</span><span id="line-966"></span><span>                  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span>       </span><span class="hs-comment">-- Binders of those bindings</span><span>
</span><span id="line-967"></span><span>                  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html#VarSet"><span class="hs-identifier hs-type">VarSet</span></a></span><span>       </span><span class="hs-comment">-- Free vars of those bindings + rhs of user rules</span><span>
</span><span id="line-968"></span><span>                                 </span><span class="hs-comment">-- (we don't bother to delete the binders)</span><span>
</span><span id="line-969"></span><span>                  </span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.html#CoreRule"><span class="hs-identifier hs-type">CoreRule</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- All rules, imported + from the bindings</span><span>
</span><span id="line-970"></span><span>    </span><span class="hs-comment">-- This function removes unnecessary bindings, and gathers up rules from</span><span>
</span><span id="line-971"></span><span>    </span><span class="hs-comment">-- the bindings we keep.  See Note [Trimming auto-rules]</span><span>
</span><span id="line-972"></span><span>    </span><span id="local-6989586621681180850"><span class="annot"><span class="annottext">trim_binds :: CoreProgram -&gt; (CoreProgram, VarSet, VarSet, [CoreRule])
</span><a href="#local-6989586621681180850"><span class="hs-identifier hs-var hs-var">trim_binds</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>  </span><span class="hs-comment">-- Base case, start with imp_user_rule_fvs</span><span>
</span><span id="line-973"></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="GHC.Types.Var.Set.html#emptyVarSet"><span class="hs-identifier hs-var">emptyVarSet</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681180855"><span class="hs-identifier hs-var">imp_user_rule_fvs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621681180857"><span class="hs-identifier hs-var">imp_rules</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-974"></span><span>
</span><span id="line-975"></span><span>    </span><span class="annot"><a href="#local-6989586621681180850"><span class="hs-identifier hs-var">trim_binds</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681180838"><span class="annot"><span class="annottext">CoreBind
</span><a href="#local-6989586621681180838"><span class="hs-identifier hs-var">bind</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621681180837"><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621681180837"><span class="hs-identifier hs-var">binds</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-976"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">(Id -&gt; Bool) -&gt; [Id] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#any"><span class="hs-identifier hs-var">any</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="#local-6989586621681180835"><span class="hs-identifier hs-var">needed</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681180834"><span class="hs-identifier hs-var">bndrs</span></a></span><span>    </span><span class="hs-comment">-- Keep binding</span><span>
</span><span id="line-977"></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">CoreBind
</span><a href="#local-6989586621681180838"><span class="hs-identifier hs-var">bind</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBind -&gt; CoreProgram -&gt; CoreProgram
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621681180833"><span class="hs-identifier hs-var">binds'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681180832"><span class="hs-identifier hs-var">bndr_set'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681180831"><span class="hs-identifier hs-var">needed_fvs'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621681180830"><span class="hs-identifier hs-var">local_rules</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreRule] -&gt; [CoreRule] -&gt; [CoreRule]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621681180829"><span class="hs-identifier hs-var">rules</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-978"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>           </span><span class="hs-comment">-- Discard binding altogether</span><span>
</span><span id="line-979"></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CoreProgram, VarSet, VarSet, [CoreRule])
</span><a href="#local-6989586621681180828"><span class="hs-identifier hs-var">stuff</span></a></span><span>
</span><span id="line-980"></span><span>       </span><span class="hs-keyword">where</span><span>
</span><span id="line-981"></span><span>         </span><span id="local-6989586621681180828"><span class="annot"><span class="annottext">stuff :: (CoreProgram, VarSet, VarSet, [CoreRule])
</span><a href="#local-6989586621681180828"><span class="hs-identifier hs-var">stuff</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span id="local-6989586621681180833"><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621681180833"><span class="hs-identifier hs-var">binds'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681180827"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681180827"><span class="hs-identifier hs-var">bndr_set</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681180826"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681180826"><span class="hs-identifier hs-var">needed_fvs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681180829"><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621681180829"><span class="hs-identifier hs-var">rules</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-982"></span><span>                       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreProgram -&gt; (CoreProgram, VarSet, VarSet, [CoreRule])
</span><a href="#local-6989586621681180850"><span class="hs-identifier hs-var">trim_binds</span></a></span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621681180837"><span class="hs-identifier hs-var">binds</span></a></span><span>
</span><span id="line-983"></span><span>         </span><span id="local-6989586621681180835"><span class="annot"><span class="annottext">needed :: Id -&gt; Bool
</span><a href="#local-6989586621681180835"><span class="hs-identifier hs-var hs-var">needed</span></a></span></span><span> </span><span id="local-6989586621681180825"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180825"><span class="hs-identifier hs-var">bndr</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="GHC.Types.Var.html#isExportedId"><span class="hs-identifier hs-var">isExportedId</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180825"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180825"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#elemVarSet"><span class="hs-operator hs-var">`elemVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681180826"><span class="hs-identifier hs-var">needed_fvs</span></a></span><span>
</span><span id="line-984"></span><span>
</span><span id="line-985"></span><span>         </span><span id="local-6989586621681180834"><span class="annot"><span class="annottext">bndrs :: [Id]
</span><a href="#local-6989586621681180834"><span class="hs-identifier hs-var hs-var">bndrs</span></a></span></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreBind -&gt; [Id]
forall b. Bind b -&gt; [b]
</span><a href="GHC.Core.html#bindersOf"><span class="hs-identifier hs-var">bindersOf</span></a></span><span>  </span><span class="annot"><span class="annottext">CoreBind
</span><a href="#local-6989586621681180838"><span class="hs-identifier hs-var">bind</span></a></span><span>
</span><span id="line-986"></span><span>         </span><span id="local-6989586621681180823"><span class="annot"><span class="annottext">rhss :: [Expr Id]
</span><a href="#local-6989586621681180823"><span class="hs-identifier hs-var hs-var">rhss</span></a></span></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoreBind -&gt; [Expr Id]
forall b. Bind b -&gt; [Expr b]
</span><a href="GHC.Core.html#rhssOfBind"><span class="hs-identifier hs-var">rhssOfBind</span></a></span><span> </span><span class="annot"><span class="annottext">CoreBind
</span><a href="#local-6989586621681180838"><span class="hs-identifier hs-var">bind</span></a></span><span>
</span><span id="line-987"></span><span>         </span><span id="local-6989586621681180832"><span class="annot"><span class="annottext">bndr_set' :: VarSet
</span><a href="#local-6989586621681180832"><span class="hs-identifier hs-var hs-var">bndr_set'</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681180827"><span class="hs-identifier hs-var">bndr_set</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; [Id] -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#extendVarSetList"><span class="hs-operator hs-var">`extendVarSetList`</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681180834"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-988"></span><span>
</span><span id="line-989"></span><span>         </span><span id="local-6989586621681180831"><span class="annot"><span class="annottext">needed_fvs' :: VarSet
</span><a href="#local-6989586621681180831"><span class="hs-identifier hs-var hs-var">needed_fvs'</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681180826"><span class="hs-identifier hs-var">needed_fvs</span></a></span><span>                                   </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#unionVarSet"><span class="hs-operator hs-var">`unionVarSet`</span></a></span><span>
</span><span id="line-990"></span><span>                         </span><span class="annot"><span class="annottext">(Id -&gt; VarSet) -&gt; [Id] -&gt; VarSet
forall a. (a -&gt; VarSet) -&gt; [a] -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#mapUnionVarSet"><span class="hs-identifier hs-var">mapUnionVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; VarSet
</span><a href="GHC.Core.FVs.html#idUnfoldingVars"><span class="hs-identifier hs-var">idUnfoldingVars</span></a></span><span>   </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681180834"><span class="hs-identifier hs-var">bndrs</span></a></span><span>       </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#unionVarSet"><span class="hs-operator hs-var">`unionVarSet`</span></a></span><span>
</span><span id="line-991"></span><span>                              </span><span class="hs-comment">-- Ignore type variables in the type of bndrs</span><span>
</span><span id="line-992"></span><span>                         </span><span class="annot"><span class="annottext">(Expr Id -&gt; VarSet) -&gt; [Expr Id] -&gt; VarSet
forall a. (a -&gt; VarSet) -&gt; [a] -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#mapUnionVarSet"><span class="hs-identifier hs-var">mapUnionVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">Expr Id -&gt; VarSet
</span><a href="GHC.Core.FVs.html#exprFreeVars"><span class="hs-identifier hs-var">exprFreeVars</span></a></span><span>      </span><span class="annot"><span class="annottext">[Expr Id]
</span><a href="#local-6989586621681180823"><span class="hs-identifier hs-var">rhss</span></a></span><span>        </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#unionVarSet"><span class="hs-operator hs-var">`unionVarSet`</span></a></span><span>
</span><span id="line-993"></span><span>                         </span><span class="annot"><span class="annottext">(CoreRule -&gt; VarSet) -&gt; [CoreRule] -&gt; VarSet
forall a. (a -&gt; VarSet) -&gt; [a] -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#mapUnionVarSet"><span class="hs-identifier hs-var">mapUnionVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">CoreRule -&gt; VarSet
</span><a href="#local-6989586621681180854"><span class="hs-identifier hs-var">user_rule_rhs_fvs</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreRule]
</span><a href="#local-6989586621681180830"><span class="hs-identifier hs-var">local_rules</span></a></span><span>
</span><span id="line-994"></span><span>            </span><span class="hs-comment">-- In needed_fvs', we don't bother to delete binders from the fv set</span><span>
</span><span id="line-995"></span><span>
</span><span id="line-996"></span><span>         </span><span id="local-6989586621681180830"><span class="annot"><span class="annottext">local_rules :: [CoreRule]
</span><a href="#local-6989586621681180830"><span class="hs-identifier hs-var hs-var">local_rules</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">CoreRule
</span><a href="#local-6989586621681180818"><span class="hs-identifier hs-var">rule</span></a></span><span>
</span><span id="line-997"></span><span>                        </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621681180817"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180817"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681180834"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-998"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Bool
</span><a href="#local-6989586621681180843"><span class="hs-identifier hs-var">is_external_id</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180817"><span class="hs-identifier hs-var">id</span></a></span><span>   </span><span class="hs-comment">-- Only collect rules for external Ids</span><span>
</span><span id="line-999"></span><span>                        </span><span class="hs-special">,</span><span> </span><span id="local-6989586621681180818"><span class="annot"><span class="annottext">CoreRule
</span><a href="#local-6989586621681180818"><span class="hs-identifier hs-var">rule</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Id -&gt; [CoreRule]
</span><a href="GHC.Types.Id.html#idCoreRules"><span class="hs-identifier hs-var">idCoreRules</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180817"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-1000"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoreRule -&gt; Bool
</span><a href="#local-6989586621681180856"><span class="hs-identifier hs-var">expose_rule</span></a></span><span> </span><span class="annot"><span class="annottext">CoreRule
</span><a href="#local-6989586621681180818"><span class="hs-identifier hs-var">rule</span></a></span><span> </span><span class="hs-special">]</span><span>  </span><span class="hs-comment">-- and ones that can fire in a client</span><span>
</span><span id="line-1001"></span><span>
</span><span id="line-1002"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
               tidyTopName
*                                                                      *
************************************************************************

This is where we set names to local/global based on whether they really are
externally visible (see comment at the top of this module).  If the name
was previously local, we have to give it a unique occurrence name if
we intend to externalise it.
-}</span><span>
</span><span id="line-1014"></span><span>
</span><span id="line-1015"></span><span class="annot"><a href="GHC.Iface.Tidy.html#tidyTopName"><span class="hs-identifier hs-type">tidyTopName</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Unit.Types.html#Module"><span class="hs-identifier hs-type">Module</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.IORef.html#IORef"><span class="hs-identifier hs-type">IORef</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.Cache.html#NameCache"><span class="hs-identifier hs-type">NameCache</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Name.Occurrence.html#TidyOccEnv"><span class="hs-identifier hs-type">TidyOccEnv</span></a></span><span>
</span><span id="line-1016"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Name.Occurrence.html#TidyOccEnv"><span class="hs-identifier hs-type">TidyOccEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1017"></span><span id="tidyTopName"><span class="annot"><span class="annottext">tidyTopName :: Module
-&gt; IORef NameCache
-&gt; Maybe Id
-&gt; TidyOccEnv
-&gt; Id
-&gt; IO (TidyOccEnv, Name)
</span><a href="GHC.Iface.Tidy.html#tidyTopName"><span class="hs-identifier hs-var hs-var">tidyTopName</span></a></span></span><span> </span><span id="local-6989586621681180815"><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681180815"><span class="hs-identifier hs-var">mod</span></a></span></span><span> </span><span id="local-6989586621681180814"><span class="annot"><span class="annottext">IORef NameCache
</span><a href="#local-6989586621681180814"><span class="hs-identifier hs-var">nc_var</span></a></span></span><span> </span><span id="local-6989586621681180813"><span class="annot"><span class="annottext">Maybe Id
</span><a href="#local-6989586621681180813"><span class="hs-identifier hs-var">maybe_ref</span></a></span></span><span> </span><span id="local-6989586621681180812"><span class="annot"><span class="annottext">TidyOccEnv
</span><a href="#local-6989586621681180812"><span class="hs-identifier hs-var">occ_env</span></a></span></span><span> </span><span id="local-6989586621681180811"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180811"><span class="hs-identifier hs-var">id</span></a></span></span><span>
</span><span id="line-1018"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681180810"><span class="hs-identifier hs-var">global</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681180809"><span class="hs-identifier hs-var">internal</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TidyOccEnv, Name) -&gt; IO (TidyOccEnv, Name)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TidyOccEnv
</span><a href="#local-6989586621681180812"><span class="hs-identifier hs-var">occ_env</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Name -&gt; Name
</span><a href="GHC.Types.Name.html#localiseName"><span class="hs-identifier hs-var">localiseName</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681180807"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1019"></span><span>
</span><span id="line-1020"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681180810"><span class="hs-identifier hs-var">global</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681180806"><span class="hs-identifier hs-var">external</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TidyOccEnv, Name) -&gt; IO (TidyOccEnv, Name)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TidyOccEnv
</span><a href="#local-6989586621681180812"><span class="hs-identifier hs-var">occ_env</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681180807"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1021"></span><span>        </span><span class="hs-comment">-- Global names are assumed to have been allocated by the renamer,</span><span>
</span><span id="line-1022"></span><span>        </span><span class="hs-comment">-- so they already have the &quot;right&quot; unique</span><span>
</span><span id="line-1023"></span><span>        </span><span class="hs-comment">-- And it's a system-wide unique too</span><span>
</span><span id="line-1024"></span><span>
</span><span id="line-1025"></span><span>  </span><span class="hs-comment">-- Now we get to the real reason that all this is in the IO Monad:</span><span>
</span><span id="line-1026"></span><span>  </span><span class="hs-comment">-- we have to update the name cache in a nice atomic fashion</span><span>
</span><span id="line-1027"></span><span>
</span><span id="line-1028"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681180805"><span class="hs-identifier hs-var">local</span></a></span><span>  </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681180809"><span class="hs-identifier hs-var">internal</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681180804"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681180804"><span class="hs-identifier hs-var">new_local_name</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef NameCache -&gt; (NameCache -&gt; (NameCache, Name)) -&gt; IO Name
forall a b. IORef a -&gt; (a -&gt; (a, b)) -&gt; IO b
</span><a href="../../base/src/GHC.IORef.html#atomicModifyIORef%27"><span class="hs-identifier hs-var">atomicModifyIORef'</span></a></span><span> </span><span class="annot"><span class="annottext">IORef NameCache
</span><a href="#local-6989586621681180814"><span class="hs-identifier hs-var">nc_var</span></a></span><span> </span><span class="annot"><span class="annottext">NameCache -&gt; (NameCache, Name)
</span><a href="#local-6989586621681180803"><span class="hs-identifier hs-var">mk_new_local</span></a></span><span>
</span><span id="line-1029"></span><span>                            </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(TidyOccEnv, Name) -&gt; IO (TidyOccEnv, Name)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TidyOccEnv
</span><a href="#local-6989586621681180802"><span class="hs-identifier hs-var">occ_env'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681180804"><span class="hs-identifier hs-var">new_local_name</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1030"></span><span>        </span><span class="hs-comment">-- Even local, internal names must get a unique occurrence, because</span><span>
</span><span id="line-1031"></span><span>        </span><span class="hs-comment">-- if we do -split-objs we externalise the name later, in the code generator</span><span>
</span><span id="line-1032"></span><span>        </span><span class="hs-comment">--</span><span>
</span><span id="line-1033"></span><span>        </span><span class="hs-comment">-- Similarly, we must make sure it has a system-wide Unique, because</span><span>
</span><span id="line-1034"></span><span>        </span><span class="hs-comment">-- the byte-code generator builds a system-wide Name-&gt;BCO symbol table</span><span>
</span><span id="line-1035"></span><span>
</span><span id="line-1036"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681180805"><span class="hs-identifier hs-var">local</span></a></span><span>  </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681180806"><span class="hs-identifier hs-var">external</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681180801"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681180801"><span class="hs-identifier hs-var">new_external_name</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IORef NameCache -&gt; (NameCache -&gt; (NameCache, Name)) -&gt; IO Name
forall a b. IORef a -&gt; (a -&gt; (a, b)) -&gt; IO b
</span><a href="../../base/src/GHC.IORef.html#atomicModifyIORef%27"><span class="hs-identifier hs-var">atomicModifyIORef'</span></a></span><span> </span><span class="annot"><span class="annottext">IORef NameCache
</span><a href="#local-6989586621681180814"><span class="hs-identifier hs-var">nc_var</span></a></span><span> </span><span class="annot"><span class="annottext">NameCache -&gt; (NameCache, Name)
</span><a href="#local-6989586621681180800"><span class="hs-identifier hs-var">mk_new_external</span></a></span><span>
</span><span id="line-1037"></span><span>                            </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(TidyOccEnv, Name) -&gt; IO (TidyOccEnv, Name)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TidyOccEnv
</span><a href="#local-6989586621681180802"><span class="hs-identifier hs-var">occ_env'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681180801"><span class="hs-identifier hs-var">new_external_name</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1038"></span><span>
</span><span id="line-1039"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO (TidyOccEnv, Name)
forall a. String -&gt; a
</span><a href="GHC.Utils.Panic.Plain.html#panic"><span class="hs-identifier hs-var">panic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;tidyTopName&quot;</span></span><span>
</span><span id="line-1040"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1041"></span><span>    </span><span id="local-6989586621681180807"><span class="annot"><span class="annottext">name :: Name
</span><a href="#local-6989586621681180807"><span class="hs-identifier hs-var hs-var">name</span></a></span></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Name
</span><a href="GHC.Types.Id.html#idName"><span class="hs-identifier hs-var">idName</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180811"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-1042"></span><span>    </span><span id="local-6989586621681180806"><span class="annot"><span class="annottext">external :: Bool
</span><a href="#local-6989586621681180806"><span class="hs-identifier hs-var hs-var">external</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe Id -&gt; Bool
forall a. Maybe a -&gt; Bool
</span><a href="../../base/src/Data.Maybe.html#isJust"><span class="hs-identifier hs-var">isJust</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Id
</span><a href="#local-6989586621681180813"><span class="hs-identifier hs-var">maybe_ref</span></a></span><span>
</span><span id="line-1043"></span><span>    </span><span id="local-6989586621681180810"><span class="annot"><span class="annottext">global :: Bool
</span><a href="#local-6989586621681180810"><span class="hs-identifier hs-var hs-var">global</span></a></span></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name -&gt; Bool
</span><a href="GHC.Types.Name.html#isExternalName"><span class="hs-identifier hs-var">isExternalName</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681180807"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-1044"></span><span>    </span><span id="local-6989586621681180805"><span class="annot"><span class="annottext">local :: Bool
</span><a href="#local-6989586621681180805"><span class="hs-identifier hs-var hs-var">local</span></a></span></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681180810"><span class="hs-identifier hs-var">global</span></a></span><span>
</span><span id="line-1045"></span><span>    </span><span id="local-6989586621681180809"><span class="annot"><span class="annottext">internal :: Bool
</span><a href="#local-6989586621681180809"><span class="hs-identifier hs-var hs-var">internal</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681180806"><span class="hs-identifier hs-var">external</span></a></span><span>
</span><span id="line-1046"></span><span>    </span><span id="local-6989586621681180797"><span class="annot"><span class="annottext">loc :: SrcSpan
</span><a href="#local-6989586621681180797"><span class="hs-identifier hs-var hs-var">loc</span></a></span></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name -&gt; SrcSpan
</span><a href="GHC.Types.Name.html#nameSrcSpan"><span class="hs-identifier hs-var">nameSrcSpan</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681180807"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-1047"></span><span>
</span><span id="line-1048"></span><span>    </span><span id="local-6989586621681180795"><span class="annot"><span class="annottext">old_occ :: OccName
</span><a href="#local-6989586621681180795"><span class="hs-identifier hs-var hs-var">old_occ</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name -&gt; OccName
</span><a href="GHC.Types.Name.html#nameOccName"><span class="hs-identifier hs-var">nameOccName</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681180807"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-1049"></span><span>    </span><span id="local-6989586621681180791"><span class="annot"><span class="annottext">new_occ :: OccName
</span><a href="#local-6989586621681180791"><span class="hs-identifier hs-var hs-var">new_occ</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681180790"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180790"><span class="hs-identifier hs-var">ref</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Maybe Id
</span><a href="#local-6989586621681180813"><span class="hs-identifier hs-var">maybe_ref</span></a></span><span>
</span><span id="line-1050"></span><span>            </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180790"><span class="hs-identifier hs-var">ref</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Id -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">/=</span></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180811"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-1051"></span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NameSpace -&gt; String -&gt; OccName
</span><a href="GHC.Types.Name.Occurrence.html#mkOccName"><span class="hs-identifier hs-var">mkOccName</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OccName -&gt; NameSpace
</span><a href="GHC.Types.Name.Occurrence.html#occNameSpace"><span class="hs-identifier hs-var hs-var">occNameSpace</span></a></span><span> </span><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621681180795"><span class="hs-identifier hs-var">old_occ</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(String -&gt; OccName) -&gt; String -&gt; OccName
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1052"></span><span>                   </span><span class="hs-keyword">let</span><span>
</span><span id="line-1053"></span><span>                       </span><span id="local-6989586621681180785"><span class="annot"><span class="annottext">ref_str :: String
</span><a href="#local-6989586621681180785"><span class="hs-identifier hs-var hs-var">ref_str</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccName -&gt; String
</span><a href="GHC.Types.Name.Occurrence.html#occNameString"><span class="hs-identifier hs-var">occNameString</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; OccName
forall a. NamedThing a =&gt; a -&gt; OccName
</span><a href="GHC.Types.Name.html#getOccName"><span class="hs-identifier hs-var">getOccName</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180790"><span class="hs-identifier hs-var">ref</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1054"></span><span>                       </span><span id="local-6989586621681180783"><span class="annot"><span class="annottext">occ_str :: String
</span><a href="#local-6989586621681180783"><span class="hs-identifier hs-var hs-var">occ_str</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccName -&gt; String
</span><a href="GHC.Types.Name.Occurrence.html#occNameString"><span class="hs-identifier hs-var">occNameString</span></a></span><span> </span><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621681180795"><span class="hs-identifier hs-var">old_occ</span></a></span><span>
</span><span id="line-1055"></span><span>                   </span><span class="hs-keyword">in</span><span>
</span><span id="line-1056"></span><span>                   </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681180783"><span class="hs-identifier hs-var">occ_str</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1057"></span><span>                     </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'$'</span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'w'</span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span class="annot"><span class="annottext">String
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681180783"><span class="hs-identifier hs-var">occ_str</span></a></span><span>
</span><span id="line-1058"></span><span>                        </span><span class="hs-comment">-- workers: the worker for a function already</span><span>
</span><span id="line-1059"></span><span>                        </span><span class="hs-comment">-- includes the occname for its parent, so there's</span><span>
</span><span id="line-1060"></span><span>                        </span><span class="hs-comment">-- no need to prepend the referrer.</span><span>
</span><span id="line-1061"></span><span>                     </span><span id="local-6989586621681180782"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681180782"><span class="hs-identifier hs-var">_other</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Name -&gt; Bool
</span><a href="GHC.Types.Name.html#isSystemName"><span class="hs-identifier hs-var">isSystemName</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681180807"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681180785"><span class="hs-identifier hs-var">ref_str</span></a></span><span>
</span><span id="line-1062"></span><span>                            </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681180785"><span class="hs-identifier hs-var">ref_str</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'_'</span></span><span> </span><span class="annot"><span class="annottext">Char -&gt; String -&gt; String
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681180783"><span class="hs-identifier hs-var">occ_str</span></a></span><span>
</span><span id="line-1063"></span><span>                        </span><span class="hs-comment">-- If this name was system-generated, then don't bother</span><span>
</span><span id="line-1064"></span><span>                        </span><span class="hs-comment">-- to retain its OccName, just use the referrer.  These</span><span>
</span><span id="line-1065"></span><span>                        </span><span class="hs-comment">-- system-generated names will become &quot;f1&quot;, &quot;f2&quot;, etc. for</span><span>
</span><span id="line-1066"></span><span>                        </span><span class="hs-comment">-- a referrer &quot;f&quot;.</span><span>
</span><span id="line-1067"></span><span>            </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621681180795"><span class="hs-identifier hs-var">old_occ</span></a></span><span>
</span><span id="line-1068"></span><span>
</span><span id="line-1069"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621681180802"><span class="annot"><span class="annottext">TidyOccEnv
</span><a href="#local-6989586621681180802"><span class="hs-identifier hs-var">occ_env'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681180780"><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621681180780"><span class="hs-identifier hs-var">occ'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TidyOccEnv -&gt; OccName -&gt; (TidyOccEnv, OccName)
</span><a href="GHC.Types.Name.Occurrence.html#tidyOccName"><span class="hs-identifier hs-var">tidyOccName</span></a></span><span> </span><span class="annot"><span class="annottext">TidyOccEnv
</span><a href="#local-6989586621681180812"><span class="hs-identifier hs-var">occ_env</span></a></span><span> </span><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621681180791"><span class="hs-identifier hs-var">new_occ</span></a></span><span>
</span><span id="line-1070"></span><span>
</span><span id="line-1071"></span><span>    </span><span id="local-6989586621681180803"><span class="annot"><span class="annottext">mk_new_local :: NameCache -&gt; (NameCache, Name)
</span><a href="#local-6989586621681180803"><span class="hs-identifier hs-var hs-var">mk_new_local</span></a></span></span><span> </span><span id="local-6989586621681180778"><span class="annot"><span class="annottext">NameCache
</span><a href="#local-6989586621681180778"><span class="hs-identifier hs-var">nc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">NameCache
</span><a href="#local-6989586621681180778"><span class="hs-identifier hs-var">nc</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">nsUniqs :: UniqSupply
</span><a href="GHC.Types.Name.Cache.html#nsUniqs"><span class="hs-identifier hs-var">nsUniqs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UniqSupply
</span><a href="#local-6989586621681180776"><span class="hs-identifier hs-var">us</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Unique -&gt; OccName -&gt; SrcSpan -&gt; Name
</span><a href="GHC.Types.Name.html#mkInternalName"><span class="hs-identifier hs-var">mkInternalName</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681180774"><span class="hs-identifier hs-var">uniq</span></a></span><span> </span><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621681180780"><span class="hs-identifier hs-var">occ'</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681180797"><span class="hs-identifier hs-var">loc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1072"></span><span>                    </span><span class="hs-keyword">where</span><span>
</span><span id="line-1073"></span><span>                      </span><span class="hs-special">(</span><span id="local-6989586621681180774"><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681180774"><span class="hs-identifier hs-var">uniq</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681180776"><span class="annot"><span class="annottext">UniqSupply
</span><a href="#local-6989586621681180776"><span class="hs-identifier hs-var">us</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UniqSupply -&gt; (Unique, UniqSupply)
</span><a href="GHC.Types.Unique.Supply.html#takeUniqFromSupply"><span class="hs-identifier hs-var">takeUniqFromSupply</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">NameCache -&gt; UniqSupply
</span><a href="GHC.Types.Name.Cache.html#nsUniqs"><span class="hs-identifier hs-var hs-var">nsUniqs</span></a></span><span> </span><span class="annot"><span class="annottext">NameCache
</span><a href="#local-6989586621681180778"><span class="hs-identifier hs-var">nc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1074"></span><span>
</span><span id="line-1075"></span><span>    </span><span id="local-6989586621681180800"><span class="annot"><span class="annottext">mk_new_external :: NameCache -&gt; (NameCache, Name)
</span><a href="#local-6989586621681180800"><span class="hs-identifier hs-var hs-var">mk_new_external</span></a></span></span><span> </span><span id="local-6989586621681180772"><span class="annot"><span class="annottext">NameCache
</span><a href="#local-6989586621681180772"><span class="hs-identifier hs-var">nc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NameCache -&gt; Module -&gt; OccName -&gt; SrcSpan -&gt; (NameCache, Name)
</span><a href="GHC.Iface.Env.html#allocateGlobalBinder"><span class="hs-identifier hs-var">allocateGlobalBinder</span></a></span><span> </span><span class="annot"><span class="annottext">NameCache
</span><a href="#local-6989586621681180772"><span class="hs-identifier hs-var">nc</span></a></span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681180815"><span class="hs-identifier hs-var">mod</span></a></span><span> </span><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621681180780"><span class="hs-identifier hs-var">occ'</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681180797"><span class="hs-identifier hs-var">loc</span></a></span><span>
</span><span id="line-1076"></span><span>        </span><span class="hs-comment">-- If we want to externalise a currently-local name, check</span><span>
</span><span id="line-1077"></span><span>        </span><span class="hs-comment">-- whether we have already assigned a unique for it.</span><span>
</span><span id="line-1078"></span><span>        </span><span class="hs-comment">-- If so, use it; if not, extend the table.</span><span>
</span><span id="line-1079"></span><span>        </span><span class="hs-comment">-- All this is done by allcoateGlobalBinder.</span><span>
</span><span id="line-1080"></span><span>        </span><span class="hs-comment">-- This is needed when *re*-compiling a module in GHCi; we must</span><span>
</span><span id="line-1081"></span><span>        </span><span class="hs-comment">-- use the same name for externally-visible things as we did before.</span><span>
</span><span id="line-1082"></span><span>
</span><span id="line-1083"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
\subsection{Step 2: top-level tidying}
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-1090"></span><span>
</span><span id="line-1091"></span><span class="hs-comment">-- TopTidyEnv: when tidying we need to know</span><span>
</span><span id="line-1092"></span><span class="hs-comment">--   * nc_var: The NameCache, containing a unique supply and any pre-ordained Names.</span><span>
</span><span id="line-1093"></span><span class="hs-comment">--        These may have arisen because the</span><span>
</span><span id="line-1094"></span><span class="hs-comment">--        renamer read in an interface file mentioning M.$wf, say,</span><span>
</span><span id="line-1095"></span><span class="hs-comment">--        and assigned it unique r77.  If, on this compilation, we've</span><span>
</span><span id="line-1096"></span><span class="hs-comment">--        invented an Id whose name is $wf (but with a different unique)</span><span>
</span><span id="line-1097"></span><span class="hs-comment">--        we want to rename it to have unique r77, so that we can do easy</span><span>
</span><span id="line-1098"></span><span class="hs-comment">--        comparisons with stuff from the interface file</span><span>
</span><span id="line-1099"></span><span class="hs-comment">--</span><span>
</span><span id="line-1100"></span><span class="hs-comment">--   * occ_env: The TidyOccEnv, which tells us which local occurrences</span><span>
</span><span id="line-1101"></span><span class="hs-comment">--     are 'used'</span><span>
</span><span id="line-1102"></span><span class="hs-comment">--</span><span>
</span><span id="line-1103"></span><span class="hs-comment">--   * subst_env: A Var-&gt;Var mapping that substitutes the new Var for the old</span><span>
</span><span id="line-1104"></span><span>
</span><span id="line-1105"></span><span class="annot"><a href="GHC.Iface.Tidy.html#tidyTopBinds"><span class="hs-identifier hs-type">tidyTopBinds</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Types.html#HscEnv"><span class="hs-identifier hs-type">HscEnv</span></a></span><span>
</span><span id="line-1106"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Iface.Tidy.html#UnfoldEnv"><span class="hs-identifier hs-type">UnfoldEnv</span></a></span><span>
</span><span id="line-1107"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Name.Occurrence.html#TidyOccEnv"><span class="hs-identifier hs-type">TidyOccEnv</span></a></span><span>
</span><span id="line-1108"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreProgram"><span class="hs-identifier hs-type">CoreProgram</span></a></span><span>
</span><span id="line-1109"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.Env.html#TidyEnv"><span class="hs-identifier hs-type">TidyEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreProgram"><span class="hs-identifier hs-type">CoreProgram</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1110"></span><span>
</span><span id="line-1111"></span><span id="tidyTopBinds"><span class="annot"><span class="annottext">tidyTopBinds :: HscEnv
-&gt; UnfoldEnv
-&gt; TidyOccEnv
-&gt; CoreProgram
-&gt; IO (TidyEnv, CoreProgram)
</span><a href="GHC.Iface.Tidy.html#tidyTopBinds"><span class="hs-identifier hs-var hs-var">tidyTopBinds</span></a></span></span><span> </span><span id="local-6989586621681180770"><span class="annot"><span class="annottext">HscEnv
</span><a href="#local-6989586621681180770"><span class="hs-identifier hs-var">hsc_env</span></a></span></span><span> </span><span id="local-6989586621681180769"><span class="annot"><span class="annottext">UnfoldEnv
</span><a href="#local-6989586621681180769"><span class="hs-identifier hs-var">unfold_env</span></a></span></span><span> </span><span id="local-6989586621681180768"><span class="annot"><span class="annottext">TidyOccEnv
</span><a href="#local-6989586621681180768"><span class="hs-identifier hs-var">init_occ_env</span></a></span></span><span> </span><span id="local-6989586621681180767"><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621681180767"><span class="hs-identifier hs-var">binds</span></a></span></span><span>
</span><span id="line-1112"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681180766"><span class="annot"><span class="annottext">result :: (TidyEnv, CoreProgram)
</span><a href="#local-6989586621681180766"><span class="hs-identifier hs-var hs-var">result</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; CoreProgram -&gt; (TidyEnv, CoreProgram)
</span><a href="#local-6989586621681180765"><span class="hs-identifier hs-var">tidy</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
forall {a}. (TidyOccEnv, VarEnv a)
</span><a href="#local-6989586621681180764"><span class="hs-identifier hs-var">init_env</span></a></span><span> </span><span class="annot"><span class="annottext">CoreProgram
</span><a href="#local-6989586621681180767"><span class="hs-identifier hs-var">binds</span></a></span><span>
</span><span id="line-1113"></span><span>       </span><span class="annot"><span class="annottext">CoreProgram -&gt; ()
</span><a href="GHC.Core.Seq.html#seqBinds"><span class="hs-identifier hs-var">seqBinds</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(TidyEnv, CoreProgram) -&gt; CoreProgram
forall a b. (a, b) -&gt; b
</span><a href="../../base/src/Data.Tuple.html#snd"><span class="hs-identifier hs-var">snd</span></a></span><span> </span><span class="annot"><span class="annottext">(TidyEnv, CoreProgram)
</span><a href="#local-6989586621681180766"><span class="hs-identifier hs-var">result</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">() -&gt; IO (TidyEnv, CoreProgram) -&gt; IO (TidyEnv, CoreProgram)
</span><span class="hs-operator hs-var">`seq`</span></span><span> </span><span class="annot"><span class="annottext">(TidyEnv, CoreProgram) -&gt; IO (TidyEnv, CoreProgram)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(TidyEnv, CoreProgram)
</span><a href="#local-6989586621681180766"><span class="hs-identifier hs-var">result</span></a></span><span>
</span><span id="line-1114"></span><span>       </span><span class="hs-comment">-- This seqBinds avoids a spike in space usage (see #13564)</span><span>
</span><span id="line-1115"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1116"></span><span>    </span><span id="local-6989586621681180763"><span class="annot"><span class="annottext">dflags :: DynFlags
</span><a href="#local-6989586621681180763"><span class="hs-identifier hs-var hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HscEnv -&gt; DynFlags
</span><a href="GHC.Driver.Types.html#hsc_dflags"><span class="hs-identifier hs-var hs-var">hsc_dflags</span></a></span><span> </span><span class="annot"><span class="annottext">HscEnv
</span><a href="#local-6989586621681180770"><span class="hs-identifier hs-var">hsc_env</span></a></span><span>
</span><span id="line-1117"></span><span>
</span><span id="line-1118"></span><span>    </span><span id="local-6989586621681180764"><span class="annot"><span class="annottext">init_env :: (TidyOccEnv, VarEnv a)
</span><a href="#local-6989586621681180764"><span class="hs-identifier hs-var hs-var">init_env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TidyOccEnv
</span><a href="#local-6989586621681180768"><span class="hs-identifier hs-var">init_occ_env</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">VarEnv a
forall a. VarEnv a
</span><a href="GHC.Types.Var.Env.html#emptyVarEnv"><span class="hs-identifier hs-var">emptyVarEnv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1119"></span><span>
</span><span id="line-1120"></span><span>    </span><span id="local-6989586621681180765"><span class="annot"><span class="annottext">tidy :: TidyEnv -&gt; CoreProgram -&gt; (TidyEnv, CoreProgram)
</span><a href="#local-6989586621681180765"><span class="hs-identifier hs-var hs-var">tidy</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TidyEnv -&gt; CoreBind -&gt; (TidyEnv, CoreBind))
-&gt; TidyEnv -&gt; CoreProgram -&gt; (TidyEnv, CoreProgram)
forall (t :: * -&gt; *) s a b.
Traversable t =&gt;
(s -&gt; a -&gt; (s, b)) -&gt; s -&gt; t a -&gt; (s, t b)
</span><a href="../../base/src/Data.Traversable.html#mapAccumL"><span class="hs-identifier hs-var">mapAccumL</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; UnfoldEnv -&gt; TidyEnv -&gt; CoreBind -&gt; (TidyEnv, CoreBind)
</span><a href="GHC.Iface.Tidy.html#tidyTopBind"><span class="hs-identifier hs-var">tidyTopBind</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681180763"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">UnfoldEnv
</span><a href="#local-6989586621681180769"><span class="hs-identifier hs-var">unfold_env</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1121"></span><span>
</span><span id="line-1122"></span><span class="hs-comment">------------------------</span><span>
</span><span id="line-1123"></span><span class="annot"><a href="GHC.Iface.Tidy.html#tidyTopBind"><span class="hs-identifier hs-type">tidyTopBind</span></a></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span>
</span><span id="line-1124"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Iface.Tidy.html#UnfoldEnv"><span class="hs-identifier hs-type">UnfoldEnv</span></a></span><span>
</span><span id="line-1125"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#TidyEnv"><span class="hs-identifier hs-type">TidyEnv</span></a></span><span>
</span><span id="line-1126"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreBind"><span class="hs-identifier hs-type">CoreBind</span></a></span><span>
</span><span id="line-1127"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.Env.html#TidyEnv"><span class="hs-identifier hs-type">TidyEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreBind"><span class="hs-identifier hs-type">CoreBind</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1128"></span><span>
</span><span id="line-1129"></span><span id="tidyTopBind"><span class="annot"><span class="annottext">tidyTopBind :: DynFlags -&gt; UnfoldEnv -&gt; TidyEnv -&gt; CoreBind -&gt; (TidyEnv, CoreBind)
</span><a href="GHC.Iface.Tidy.html#tidyTopBind"><span class="hs-identifier hs-var hs-var">tidyTopBind</span></a></span></span><span> </span><span id="local-6989586621681180759"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681180759"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681180758"><span class="annot"><span class="annottext">UnfoldEnv
</span><a href="#local-6989586621681180758"><span class="hs-identifier hs-var">unfold_env</span></a></span></span><span>
</span><span id="line-1130"></span><span>            </span><span class="hs-special">(</span><span id="local-6989586621681180757"><span class="annot"><span class="annottext">TidyOccEnv
</span><a href="#local-6989586621681180757"><span class="hs-identifier hs-var">occ_env</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681180756"><span class="annot"><span class="annottext">VarEnv Id
</span><a href="#local-6989586621681180756"><span class="hs-identifier hs-var">subst1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#NonRec"><span class="hs-identifier hs-type">NonRec</span></a></span><span> </span><span id="local-6989586621681180755"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180755"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span id="local-6989586621681180754"><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180754"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1131"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681180753"><span class="hs-identifier hs-var">tidy_env2</span></a></span><span class="hs-special">,</span><span>  </span><span class="annot"><span class="annottext">Id -&gt; Expr Id -&gt; CoreBind
forall b. b -&gt; Expr b -&gt; Bind b
</span><a href="GHC.Core.html#NonRec"><span class="hs-identifier hs-var">NonRec</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180752"><span class="hs-identifier hs-var">bndr'</span></a></span><span> </span><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180751"><span class="hs-identifier hs-var">rhs'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1132"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1133"></span><span>    </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681180750"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681180750"><span class="hs-identifier hs-var">name'</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681180749"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681180749"><span class="hs-identifier hs-var">show_unfold</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UnfoldEnv -&gt; Id -&gt; Maybe (Name, Bool)
forall a. VarEnv a -&gt; Id -&gt; Maybe a
</span><a href="GHC.Types.Var.Env.html#lookupVarEnv"><span class="hs-identifier hs-var">lookupVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">UnfoldEnv
</span><a href="#local-6989586621681180758"><span class="hs-identifier hs-var">unfold_env</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180755"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-1134"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621681180752"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180752"><span class="hs-identifier hs-var">bndr'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681180751"><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180751"><span class="hs-identifier hs-var">rhs'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags
-&gt; Bool -&gt; TidyEnv -&gt; Name -&gt; (Id, Expr Id) -&gt; (Id, Expr Id)
</span><a href="GHC.Iface.Tidy.html#tidyTopPair"><span class="hs-identifier hs-var">tidyTopPair</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681180759"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681180749"><span class="hs-identifier hs-var">show_unfold</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681180753"><span class="hs-identifier hs-var">tidy_env2</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681180750"><span class="hs-identifier hs-var">name'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180755"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180754"><span class="hs-identifier hs-var">rhs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1135"></span><span>    </span><span id="local-6989586621681180747"><span class="annot"><span class="annottext">subst2 :: VarEnv Id
</span><a href="#local-6989586621681180747"><span class="hs-identifier hs-var hs-var">subst2</span></a></span></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarEnv Id -&gt; Id -&gt; Id -&gt; VarEnv Id
forall a. VarEnv a -&gt; Id -&gt; a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#extendVarEnv"><span class="hs-identifier hs-var">extendVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">VarEnv Id
</span><a href="#local-6989586621681180756"><span class="hs-identifier hs-var">subst1</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180755"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180752"><span class="hs-identifier hs-var">bndr'</span></a></span><span>
</span><span id="line-1136"></span><span>    </span><span id="local-6989586621681180753"><span class="annot"><span class="annottext">tidy_env2 :: TidyEnv
</span><a href="#local-6989586621681180753"><span class="hs-identifier hs-var hs-var">tidy_env2</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TidyOccEnv
</span><a href="#local-6989586621681180757"><span class="hs-identifier hs-var">occ_env</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">VarEnv Id
</span><a href="#local-6989586621681180747"><span class="hs-identifier hs-var">subst2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1137"></span><span>
</span><span id="line-1138"></span><span class="annot"><a href="GHC.Iface.Tidy.html#tidyTopBind"><span class="hs-identifier hs-var">tidyTopBind</span></a></span><span> </span><span id="local-6989586621681180746"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681180746"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681180745"><span class="annot"><span class="annottext">UnfoldEnv
</span><a href="#local-6989586621681180745"><span class="hs-identifier hs-var">unfold_env</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681180744"><span class="annot"><span class="annottext">TidyOccEnv
</span><a href="#local-6989586621681180744"><span class="hs-identifier hs-var">occ_env</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681180743"><span class="annot"><span class="annottext">VarEnv Id
</span><a href="#local-6989586621681180743"><span class="hs-identifier hs-var">subst1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#Rec"><span class="hs-identifier hs-type">Rec</span></a></span><span> </span><span id="local-6989586621681180742"><span class="annot"><span class="annottext">[(Id, Expr Id)]
</span><a href="#local-6989586621681180742"><span class="hs-identifier hs-var">prs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1139"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681180741"><span class="hs-identifier hs-var">tidy_env2</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[(Id, Expr Id)] -&gt; CoreBind
forall b. [(b, Expr b)] -&gt; Bind b
</span><a href="GHC.Core.html#Rec"><span class="hs-identifier hs-var">Rec</span></a></span><span> </span><span class="annot"><span class="annottext">[(Id, Expr Id)]
</span><a href="#local-6989586621681180740"><span class="hs-identifier hs-var">prs'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1140"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1141"></span><span>    </span><span id="local-6989586621681180740"><span class="annot"><span class="annottext">prs' :: [(Id, Expr Id)]
</span><a href="#local-6989586621681180740"><span class="hs-identifier hs-var hs-var">prs'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">DynFlags
-&gt; Bool -&gt; TidyEnv -&gt; Name -&gt; (Id, Expr Id) -&gt; (Id, Expr Id)
</span><a href="GHC.Iface.Tidy.html#tidyTopPair"><span class="hs-identifier hs-var">tidyTopPair</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681180746"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681180739"><span class="hs-identifier hs-var">show_unfold</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681180741"><span class="hs-identifier hs-var">tidy_env2</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681180738"><span class="hs-identifier hs-var">name'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180737"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180736"><span class="hs-identifier hs-var">rhs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1142"></span><span>           </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681180737"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180737"><span class="hs-identifier hs-var">id</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681180736"><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180736"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[(Id, Expr Id)]
</span><a href="#local-6989586621681180742"><span class="hs-identifier hs-var">prs</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-1143"></span><span>             </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681180738"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681180738"><span class="hs-identifier hs-var">name'</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681180739"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681180739"><span class="hs-identifier hs-var">show_unfold</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-1144"></span><span>                    </span><span class="annot"><span class="annottext">String -&gt; Maybe (Name, Bool) -&gt; (Name, Bool)
forall a. HasCallStack =&gt; String -&gt; Maybe a -&gt; a
</span><a href="GHC.Data.Maybe.html#expectJust"><span class="hs-identifier hs-var">expectJust</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;tidyTopBind&quot;</span></span><span> </span><span class="annot"><span class="annottext">(Maybe (Name, Bool) -&gt; (Name, Bool))
-&gt; Maybe (Name, Bool) -&gt; (Name, Bool)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">UnfoldEnv -&gt; Id -&gt; Maybe (Name, Bool)
forall a. VarEnv a -&gt; Id -&gt; Maybe a
</span><a href="GHC.Types.Var.Env.html#lookupVarEnv"><span class="hs-identifier hs-var">lookupVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">UnfoldEnv
</span><a href="#local-6989586621681180745"><span class="hs-identifier hs-var">unfold_env</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180737"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-1145"></span><span>           </span><span class="hs-special">]</span><span>
</span><span id="line-1146"></span><span>
</span><span id="line-1147"></span><span>    </span><span id="local-6989586621681180732"><span class="annot"><span class="annottext">subst2 :: VarEnv Id
</span><a href="#local-6989586621681180732"><span class="hs-identifier hs-var hs-var">subst2</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarEnv Id -&gt; [(Id, Id)] -&gt; VarEnv Id
forall a. VarEnv a -&gt; [(Id, a)] -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#extendVarEnvList"><span class="hs-identifier hs-var">extendVarEnvList</span></a></span><span> </span><span class="annot"><span class="annottext">VarEnv Id
</span><a href="#local-6989586621681180743"><span class="hs-identifier hs-var">subst1</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681180730"><span class="hs-identifier hs-var">bndrs</span></a></span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; [Id] -&gt; [(Id, Id)]
forall a b. [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="../../base/src/GHC.List.html#zip"><span class="hs-operator hs-var">`zip`</span></a></span><span> </span><span class="annot"><span class="annottext">((Id, Expr Id) -&gt; Id) -&gt; [(Id, Expr Id)] -&gt; [Id]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">(Id, Expr Id) -&gt; Id
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span> </span><span class="annot"><span class="annottext">[(Id, Expr Id)]
</span><a href="#local-6989586621681180740"><span class="hs-identifier hs-var">prs'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1148"></span><span>    </span><span id="local-6989586621681180741"><span class="annot"><span class="annottext">tidy_env2 :: TidyEnv
</span><a href="#local-6989586621681180741"><span class="hs-identifier hs-var hs-var">tidy_env2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TidyOccEnv
</span><a href="#local-6989586621681180744"><span class="hs-identifier hs-var">occ_env</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">VarEnv Id
</span><a href="#local-6989586621681180732"><span class="hs-identifier hs-var">subst2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1149"></span><span>
</span><span id="line-1150"></span><span>    </span><span id="local-6989586621681180730"><span class="annot"><span class="annottext">bndrs :: [Id]
</span><a href="#local-6989586621681180730"><span class="hs-identifier hs-var hs-var">bndrs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((Id, Expr Id) -&gt; Id) -&gt; [(Id, Expr Id)] -&gt; [Id]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">(Id, Expr Id) -&gt; Id
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span> </span><span class="annot"><span class="annottext">[(Id, Expr Id)]
</span><a href="#local-6989586621681180742"><span class="hs-identifier hs-var">prs</span></a></span><span>
</span><span id="line-1151"></span><span>
</span><span id="line-1152"></span><span class="hs-comment">-----------------------------------------------------------</span><span>
</span><span id="line-1153"></span><span class="annot"><a href="GHC.Iface.Tidy.html#tidyTopPair"><span class="hs-identifier hs-type">tidyTopPair</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span>
</span><span id="line-1154"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>  </span><span class="hs-comment">-- show unfolding</span><span>
</span><span id="line-1155"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#TidyEnv"><span class="hs-identifier hs-type">TidyEnv</span></a></span><span>  </span><span class="hs-comment">-- The TidyEnv is used to tidy the IdInfo</span><span>
</span><span id="line-1156"></span><span>                        </span><span class="hs-comment">-- It is knot-tied: don't look at it!</span><span>
</span><span id="line-1157"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span>             </span><span class="hs-comment">-- New name</span><span>
</span><span id="line-1158"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span class="hs-special">)</span><span>   </span><span class="hs-comment">-- Binder and RHS before tidying</span><span>
</span><span id="line-1159"></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1160"></span><span>        </span><span class="hs-comment">-- This function is the heart of Step 2</span><span>
</span><span id="line-1161"></span><span>        </span><span class="hs-comment">-- The rec_tidy_env is the one to use for the IdInfo</span><span>
</span><span id="line-1162"></span><span>        </span><span class="hs-comment">-- It's necessary because when we are dealing with a recursive</span><span>
</span><span id="line-1163"></span><span>        </span><span class="hs-comment">-- group, a variable late in the group might be mentioned</span><span>
</span><span id="line-1164"></span><span>        </span><span class="hs-comment">-- in the IdInfo of one early in the group</span><span>
</span><span id="line-1165"></span><span>
</span><span id="line-1166"></span><span id="tidyTopPair"><span class="annot"><span class="annottext">tidyTopPair :: DynFlags
-&gt; Bool -&gt; TidyEnv -&gt; Name -&gt; (Id, Expr Id) -&gt; (Id, Expr Id)
</span><a href="GHC.Iface.Tidy.html#tidyTopPair"><span class="hs-identifier hs-var hs-var">tidyTopPair</span></a></span></span><span> </span><span id="local-6989586621681180729"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681180729"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681180728"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681180728"><span class="hs-identifier hs-var">show_unfold</span></a></span></span><span> </span><span id="local-6989586621681180727"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681180727"><span class="hs-identifier hs-var">rhs_tidy_env</span></a></span></span><span> </span><span id="local-6989586621681180726"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681180726"><span class="hs-identifier hs-var">name'</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681180725"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180725"><span class="hs-identifier hs-var">bndr</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681180724"><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180724"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1167"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180723"><span class="hs-identifier hs-var">bndr1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180722"><span class="hs-identifier hs-var">rhs1</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1168"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1169"></span><span>    </span><span id="local-6989586621681180723"><span class="annot"><span class="annottext">bndr1 :: Id
</span><a href="#local-6989586621681180723"><span class="hs-identifier hs-var hs-var">bndr1</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IdDetails -&gt; Name -&gt; Type -&gt; IdInfo -&gt; Id
</span><a href="GHC.Types.Id.html#mkGlobalId"><span class="hs-identifier hs-var">mkGlobalId</span></a></span><span> </span><span class="annot"><span class="annottext">IdDetails
</span><a href="#local-6989586621681180720"><span class="hs-identifier hs-var">details</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681180726"><span class="hs-identifier hs-var">name'</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681180719"><span class="hs-identifier hs-var">ty'</span></a></span><span> </span><span class="annot"><span class="annottext">IdInfo
</span><a href="#local-6989586621681180718"><span class="hs-identifier hs-var">idinfo'</span></a></span><span>
</span><span id="line-1170"></span><span>    </span><span id="local-6989586621681180720"><span class="annot"><span class="annottext">details :: IdDetails
</span><a href="#local-6989586621681180720"><span class="hs-identifier hs-var hs-var">details</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; IdDetails
</span><a href="GHC.Types.Var.html#idDetails"><span class="hs-identifier hs-var">idDetails</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180725"><span class="hs-identifier hs-var">bndr</span></a></span><span>   </span><span class="hs-comment">-- Preserve the IdDetails</span><span>
</span><span id="line-1171"></span><span>    </span><span id="local-6989586621681180719"><span class="annot"><span class="annottext">ty' :: Type
</span><a href="#local-6989586621681180719"><span class="hs-identifier hs-var hs-var">ty'</span></a></span></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Type
</span><a href="GHC.Core.TyCo.Tidy.html#tidyTopType"><span class="hs-identifier hs-var">tidyTopType</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Type
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180725"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1172"></span><span>    </span><span id="local-6989586621681180722"><span class="annot"><span class="annottext">rhs1 :: Expr Id
</span><a href="#local-6989586621681180722"><span class="hs-identifier hs-var hs-var">rhs1</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; Expr Id -&gt; Expr Id
</span><a href="GHC.Core.Tidy.html#tidyExpr"><span class="hs-identifier hs-var">tidyExpr</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681180727"><span class="hs-identifier hs-var">rhs_tidy_env</span></a></span><span> </span><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180724"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-1173"></span><span>    </span><span id="local-6989586621681180718"><span class="annot"><span class="annottext">idinfo' :: IdInfo
</span><a href="#local-6989586621681180718"><span class="hs-identifier hs-var hs-var">idinfo'</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags
-&gt; TidyEnv
-&gt; Name
-&gt; Expr Id
-&gt; Expr Id
-&gt; IdInfo
-&gt; Bool
-&gt; IdInfo
</span><a href="GHC.Iface.Tidy.html#tidyTopIdInfo"><span class="hs-identifier hs-var">tidyTopIdInfo</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681180729"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681180727"><span class="hs-identifier hs-var">rhs_tidy_env</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681180726"><span class="hs-identifier hs-var">name'</span></a></span><span> </span><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180724"><span class="hs-identifier hs-var">rhs</span></a></span><span> </span><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180722"><span class="hs-identifier hs-var">rhs1</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Id -&gt; IdInfo
Id -&gt; IdInfo
</span><a href="GHC.Types.Var.html#idInfo"><span class="hs-identifier hs-var">idInfo</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681180725"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1174"></span><span>                             </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681180728"><span class="hs-identifier hs-var">show_unfold</span></a></span><span>
</span><span id="line-1175"></span><span>
</span><span id="line-1176"></span><span class="hs-comment">-- tidyTopIdInfo creates the final IdInfo for top-level</span><span>
</span><span id="line-1177"></span><span class="hs-comment">-- binders.  The delicate piece:</span><span>
</span><span id="line-1178"></span><span class="hs-comment">--</span><span>
</span><span id="line-1179"></span><span class="hs-comment">--  * Arity.  After CoreTidy, this arity must not change any more.</span><span>
</span><span id="line-1180"></span><span class="hs-comment">--      Indeed, CorePrep must eta expand where necessary to make</span><span>
</span><span id="line-1181"></span><span class="hs-comment">--      the manifest arity equal to the claimed arity.</span><span>
</span><span id="line-1182"></span><span class="hs-comment">--</span><span>
</span><span id="line-1183"></span><span class="annot"><a href="GHC.Iface.Tidy.html#tidyTopIdInfo"><span class="hs-identifier hs-type">tidyTopIdInfo</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#TidyEnv"><span class="hs-identifier hs-type">TidyEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.html#CoreExpr"><span class="hs-identifier hs-type">CoreExpr</span></a></span><span>
</span><span id="line-1184"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Id.Info.html#IdInfo"><span class="hs-identifier hs-type">IdInfo</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Id.Info.html#IdInfo"><span class="hs-identifier hs-type">IdInfo</span></a></span><span>
</span><span id="line-1185"></span><span id="tidyTopIdInfo"><span class="annot"><span class="annottext">tidyTopIdInfo :: DynFlags
-&gt; TidyEnv
-&gt; Name
-&gt; Expr Id
-&gt; Expr Id
-&gt; IdInfo
-&gt; Bool
-&gt; IdInfo
</span><a href="GHC.Iface.Tidy.html#tidyTopIdInfo"><span class="hs-identifier hs-var hs-var">tidyTopIdInfo</span></a></span></span><span> </span><span id="local-6989586621681180712"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681180712"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681180711"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681180711"><span class="hs-identifier hs-var">rhs_tidy_env</span></a></span></span><span> </span><span id="local-6989586621681180710"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681180710"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span id="local-6989586621681180709"><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180709"><span class="hs-identifier hs-var">orig_rhs</span></a></span></span><span> </span><span id="local-6989586621681180708"><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180708"><span class="hs-identifier hs-var">tidy_rhs</span></a></span></span><span> </span><span id="local-6989586621681180707"><span class="annot"><span class="annottext">IdInfo
</span><a href="#local-6989586621681180707"><span class="hs-identifier hs-var">idinfo</span></a></span></span><span> </span><span id="local-6989586621681180706"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681180706"><span class="hs-identifier hs-var">show_unfold</span></a></span></span><span>
</span><span id="line-1186"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681180705"><span class="hs-identifier hs-var">is_external</span></a></span><span>     </span><span class="hs-comment">-- For internal Ids (not externally visible)</span><span>
</span><span id="line-1187"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IdInfo
</span><a href="GHC.Types.Id.Info.html#vanillaIdInfo"><span class="hs-identifier hs-var">vanillaIdInfo</span></a></span><span>       </span><span class="hs-comment">-- we only need enough info for code generation</span><span>
</span><span id="line-1188"></span><span>                        </span><span class="hs-comment">-- Arity and strictness info are enough;</span><span>
</span><span id="line-1189"></span><span>                        </span><span class="hs-comment">--      c.f. GHC.Core.Tidy.tidyLetBndr</span><span>
</span><span id="line-1190"></span><span>        </span><span class="annot"><span class="annottext">IdInfo -&gt; Int -&gt; IdInfo
</span><a href="GHC.Types.Id.Info.html#setArityInfo"><span class="hs-operator hs-var">`setArityInfo`</span></a></span><span>      </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681180703"><span class="hs-identifier hs-var">arity</span></a></span><span>
</span><span id="line-1191"></span><span>        </span><span class="annot"><span class="annottext">IdInfo -&gt; StrictSig -&gt; IdInfo
</span><a href="GHC.Types.Id.Info.html#setStrictnessInfo"><span class="hs-operator hs-var">`setStrictnessInfo`</span></a></span><span> </span><span class="annot"><span class="annottext">StrictSig
</span><a href="#local-6989586621681180701"><span class="hs-identifier hs-var">final_sig</span></a></span><span>
</span><span id="line-1192"></span><span>        </span><span class="annot"><span class="annottext">IdInfo -&gt; CprSig -&gt; IdInfo
</span><a href="GHC.Types.Id.Info.html#setCprInfo"><span class="hs-operator hs-var">`setCprInfo`</span></a></span><span>        </span><span class="annot"><span class="annottext">CprSig
</span><a href="#local-6989586621681180699"><span class="hs-identifier hs-var">final_cpr</span></a></span><span>
</span><span id="line-1193"></span><span>        </span><span class="annot"><span class="annottext">IdInfo -&gt; Unfolding -&gt; IdInfo
</span><a href="GHC.Types.Id.Info.html#setUnfoldingInfo"><span class="hs-operator hs-var">`setUnfoldingInfo`</span></a></span><span>  </span><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621681180697"><span class="hs-identifier hs-var">minimal_unfold_info</span></a></span><span>  </span><span class="hs-comment">-- See note [Preserve evaluatedness]</span><span>
</span><span id="line-1194"></span><span>                                                 </span><span class="hs-comment">-- in GHC.Core.Tidy</span><span>
</span><span id="line-1195"></span><span>
</span><span id="line-1196"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>           </span><span class="hs-comment">-- Externally-visible Ids get the whole lot</span><span>
</span><span id="line-1197"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IdInfo
</span><a href="GHC.Types.Id.Info.html#vanillaIdInfo"><span class="hs-identifier hs-var">vanillaIdInfo</span></a></span><span>
</span><span id="line-1198"></span><span>        </span><span class="annot"><span class="annottext">IdInfo -&gt; Int -&gt; IdInfo
</span><a href="GHC.Types.Id.Info.html#setArityInfo"><span class="hs-operator hs-var">`setArityInfo`</span></a></span><span>         </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681180703"><span class="hs-identifier hs-var">arity</span></a></span><span>
</span><span id="line-1199"></span><span>        </span><span class="annot"><span class="annottext">IdInfo -&gt; StrictSig -&gt; IdInfo
</span><a href="GHC.Types.Id.Info.html#setStrictnessInfo"><span class="hs-operator hs-var">`setStrictnessInfo`</span></a></span><span>    </span><span class="annot"><span class="annottext">StrictSig
</span><a href="#local-6989586621681180701"><span class="hs-identifier hs-var">final_sig</span></a></span><span>
</span><span id="line-1200"></span><span>        </span><span class="annot"><span class="annottext">IdInfo -&gt; CprSig -&gt; IdInfo
</span><a href="GHC.Types.Id.Info.html#setCprInfo"><span class="hs-operator hs-var">`setCprInfo`</span></a></span><span>           </span><span class="annot"><span class="annottext">CprSig
</span><a href="#local-6989586621681180699"><span class="hs-identifier hs-var">final_cpr</span></a></span><span>
</span><span id="line-1201"></span><span>        </span><span class="annot"><span class="annottext">IdInfo -&gt; OccInfo -&gt; IdInfo
</span><a href="GHC.Types.Id.Info.html#setOccInfo"><span class="hs-operator hs-var">`setOccInfo`</span></a></span><span>           </span><span class="annot"><span class="annottext">OccInfo
</span><a href="#local-6989586621681180695"><span class="hs-identifier hs-var">robust_occ_info</span></a></span><span>
</span><span id="line-1202"></span><span>        </span><span class="annot"><span class="annottext">IdInfo -&gt; InlinePragma -&gt; IdInfo
</span><a href="GHC.Types.Id.Info.html#setInlinePragInfo"><span class="hs-operator hs-var">`setInlinePragInfo`</span></a></span><span>    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IdInfo -&gt; InlinePragma
</span><a href="GHC.Types.Id.Info.html#inlinePragInfo"><span class="hs-identifier hs-var hs-var">inlinePragInfo</span></a></span><span> </span><span class="annot"><span class="annottext">IdInfo
</span><a href="#local-6989586621681180707"><span class="hs-identifier hs-var">idinfo</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1203"></span><span>        </span><span class="annot"><span class="annottext">IdInfo -&gt; Unfolding -&gt; IdInfo
</span><a href="GHC.Types.Id.Info.html#setUnfoldingInfo"><span class="hs-operator hs-var">`setUnfoldingInfo`</span></a></span><span>     </span><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621681180693"><span class="hs-identifier hs-var">unfold_info</span></a></span><span>
</span><span id="line-1204"></span><span>                </span><span class="hs-comment">-- NB: we throw away the Rules</span><span>
</span><span id="line-1205"></span><span>                </span><span class="hs-comment">-- They have already been extracted by findExternalRules</span><span>
</span><span id="line-1206"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1207"></span><span>    </span><span id="local-6989586621681180705"><span class="annot"><span class="annottext">is_external :: Bool
</span><a href="#local-6989586621681180705"><span class="hs-identifier hs-var hs-var">is_external</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name -&gt; Bool
</span><a href="GHC.Types.Name.html#isExternalName"><span class="hs-identifier hs-var">isExternalName</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681180710"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-1208"></span><span>
</span><span id="line-1209"></span><span>    </span><span class="hs-comment">--------- OccInfo ------------</span><span>
</span><span id="line-1210"></span><span>    </span><span id="local-6989586621681180695"><span class="annot"><span class="annottext">robust_occ_info :: OccInfo
</span><a href="#local-6989586621681180695"><span class="hs-identifier hs-var hs-var">robust_occ_info</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OccInfo -&gt; OccInfo
</span><a href="GHC.Types.Basic.html#zapFragileOcc"><span class="hs-identifier hs-var">zapFragileOcc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IdInfo -&gt; OccInfo
</span><a href="GHC.Types.Id.Info.html#occInfo"><span class="hs-identifier hs-var hs-var">occInfo</span></a></span><span> </span><span class="annot"><span class="annottext">IdInfo
</span><a href="#local-6989586621681180707"><span class="hs-identifier hs-var">idinfo</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1211"></span><span>    </span><span class="hs-comment">-- It's important to keep loop-breaker information</span><span>
</span><span id="line-1212"></span><span>    </span><span class="hs-comment">-- when we are doing -fexpose-all-unfoldings</span><span>
</span><span id="line-1213"></span><span>
</span><span id="line-1214"></span><span>    </span><span class="hs-comment">--------- Strictness ------------</span><span>
</span><span id="line-1215"></span><span>    </span><span id="local-6989586621681180691"><span class="annot"><span class="annottext">mb_bot_str :: Maybe (Int, StrictSig)
</span><a href="#local-6989586621681180691"><span class="hs-identifier hs-var hs-var">mb_bot_str</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Expr Id -&gt; Maybe (Int, StrictSig)
</span><a href="GHC.Core.Opt.Arity.html#exprBotStrictness_maybe"><span class="hs-identifier hs-var">exprBotStrictness_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180709"><span class="hs-identifier hs-var">orig_rhs</span></a></span><span>
</span><span id="line-1216"></span><span>
</span><span id="line-1217"></span><span>    </span><span id="local-6989586621681180690"><span class="annot"><span class="annottext">sig :: StrictSig
</span><a href="#local-6989586621681180690"><span class="hs-identifier hs-var hs-var">sig</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IdInfo -&gt; StrictSig
</span><a href="GHC.Types.Id.Info.html#strictnessInfo"><span class="hs-identifier hs-var hs-var">strictnessInfo</span></a></span><span> </span><span class="annot"><span class="annottext">IdInfo
</span><a href="#local-6989586621681180707"><span class="hs-identifier hs-var">idinfo</span></a></span><span>
</span><span id="line-1218"></span><span>    </span><span id="local-6989586621681180701"><span class="annot"><span class="annottext">final_sig :: StrictSig
</span><a href="#local-6989586621681180701"><span class="hs-identifier hs-var hs-var">final_sig</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">(Bool -&gt; Bool) -&gt; Bool -&gt; Bool
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">StrictSig -&gt; Bool
</span><a href="GHC.Types.Demand.html#isTopSig"><span class="hs-identifier hs-var">isTopSig</span></a></span><span> </span><span class="annot"><span class="annottext">StrictSig
</span><a href="#local-6989586621681180690"><span class="hs-identifier hs-var">sig</span></a></span><span>
</span><span id="line-1219"></span><span>              </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">WARN</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">_bottom_hidden</span><span> </span><span class="hs-identifier">sig</span><span> </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">ppr</span><span> </span><span class="hs-identifier">name</span><span> </span><span class="hs-special">)</span><span> </span><span class="hs-identifier">sig</span><span>
</span><span id="line-1220"></span><span>              </span><span class="hs-comment">-- try a cheap-and-cheerful bottom analyser</span><span>
</span><span id="line-1221"></span><span>              </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681180684"><span class="annot"><span class="annottext">StrictSig
</span><a href="#local-6989586621681180684"><span class="hs-identifier hs-var">nsig</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Maybe (Int, StrictSig)
</span><a href="#local-6989586621681180691"><span class="hs-identifier hs-var">mb_bot_str</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StrictSig
</span><a href="#local-6989586621681180684"><span class="hs-identifier hs-var">nsig</span></a></span><span>
</span><span id="line-1222"></span><span>              </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>                    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StrictSig
</span><a href="#local-6989586621681180690"><span class="hs-identifier hs-var">sig</span></a></span><span>
</span><span id="line-1223"></span><span>
</span><span id="line-1224"></span><span>    </span><span id="local-6989586621681180683"><span class="annot"><span class="annottext">cpr :: CprSig
</span><a href="#local-6989586621681180683"><span class="hs-identifier hs-var hs-var">cpr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IdInfo -&gt; CprSig
</span><a href="GHC.Types.Id.Info.html#cprInfo"><span class="hs-identifier hs-var hs-var">cprInfo</span></a></span><span> </span><span class="annot"><span class="annottext">IdInfo
</span><a href="#local-6989586621681180707"><span class="hs-identifier hs-var">idinfo</span></a></span><span>
</span><span id="line-1225"></span><span>    </span><span id="local-6989586621681180699"><span class="annot"><span class="annottext">final_cpr :: CprSig
</span><a href="#local-6989586621681180699"><span class="hs-identifier hs-var hs-var">final_cpr</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="annot"><span class="annottext">(Int, StrictSig)
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Maybe (Int, StrictSig)
</span><a href="#local-6989586621681180691"><span class="hs-identifier hs-var">mb_bot_str</span></a></span><span>
</span><span id="line-1226"></span><span>              </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; CprResult -&gt; CprSig
</span><a href="GHC.Types.Cpr.html#mkCprSig"><span class="hs-identifier hs-var">mkCprSig</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681180703"><span class="hs-identifier hs-var">arity</span></a></span><span> </span><span class="annot"><span class="annottext">CprResult
</span><a href="GHC.Types.Cpr.html#botCpr"><span class="hs-identifier hs-var">botCpr</span></a></span><span>
</span><span id="line-1227"></span><span>              </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1228"></span><span>              </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CprSig
</span><a href="#local-6989586621681180683"><span class="hs-identifier hs-var">cpr</span></a></span><span>
</span><span id="line-1229"></span><span>
</span><span id="line-1230"></span><span>    </span><span id="local-6989586621681180685"><span class="annot"><span class="annottext">_bottom_hidden :: StrictSig -&gt; Bool
</span><a href="#local-6989586621681180685"><span class="hs-identifier hs-var hs-var">_bottom_hidden</span></a></span></span><span> </span><span id="local-6989586621681180681"><span class="annot"><span class="annottext">StrictSig
</span><a href="#local-6989586621681180681"><span class="hs-identifier hs-var">id_sig</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe (Int, StrictSig)
</span><a href="#local-6989586621681180691"><span class="hs-identifier hs-var">mb_bot_str</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-1231"></span><span>                                  </span><span class="annot"><span class="annottext">Maybe (Int, StrictSig)
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-1232"></span><span>                                  </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681180680"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681180680"><span class="hs-identifier hs-var">arity</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">StrictSig
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">StrictSig -&gt; Int -&gt; Bool
</span><a href="GHC.Types.Demand.html#appIsDeadEnd"><span class="hs-identifier hs-var">appIsDeadEnd</span></a></span><span> </span><span class="annot"><span class="annottext">StrictSig
</span><a href="#local-6989586621681180681"><span class="hs-identifier hs-var">id_sig</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681180680"><span class="hs-identifier hs-var">arity</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1233"></span><span>
</span><span id="line-1234"></span><span>    </span><span class="hs-comment">--------- Unfolding ------------</span><span>
</span><span id="line-1235"></span><span>    </span><span id="local-6989586621681180679"><span class="annot"><span class="annottext">unf_info :: Unfolding
</span><a href="#local-6989586621681180679"><span class="hs-identifier hs-var hs-var">unf_info</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IdInfo -&gt; Unfolding
</span><a href="GHC.Types.Id.Info.html#unfoldingInfo"><span class="hs-identifier hs-var hs-var">unfoldingInfo</span></a></span><span> </span><span class="annot"><span class="annottext">IdInfo
</span><a href="#local-6989586621681180707"><span class="hs-identifier hs-var">idinfo</span></a></span><span>
</span><span id="line-1236"></span><span>    </span><span id="local-6989586621681180693"><span class="annot"><span class="annottext">unfold_info :: Unfolding
</span><a href="#local-6989586621681180693"><span class="hs-identifier hs-var hs-var">unfold_info</span></a></span></span><span>
</span><span id="line-1237"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Unfolding -&gt; Bool
</span><a href="GHC.Core.html#isCompulsoryUnfolding"><span class="hs-identifier hs-var">isCompulsoryUnfolding</span></a></span><span> </span><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621681180679"><span class="hs-identifier hs-var">unf_info</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681180706"><span class="hs-identifier hs-var">show_unfold</span></a></span><span>
</span><span id="line-1238"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; Unfolding -&gt; Unfolding -&gt; Unfolding
</span><a href="GHC.Core.Tidy.html#tidyUnfolding"><span class="hs-identifier hs-var">tidyUnfolding</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681180711"><span class="hs-identifier hs-var">rhs_tidy_env</span></a></span><span> </span><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621681180679"><span class="hs-identifier hs-var">unf_info</span></a></span><span> </span><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621681180677"><span class="hs-identifier hs-var">unf_from_rhs</span></a></span><span>
</span><span id="line-1239"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1240"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621681180697"><span class="hs-identifier hs-var">minimal_unfold_info</span></a></span><span>
</span><span id="line-1241"></span><span>    </span><span id="local-6989586621681180697"><span class="annot"><span class="annottext">minimal_unfold_info :: Unfolding
</span><a href="#local-6989586621681180697"><span class="hs-identifier hs-var hs-var">minimal_unfold_info</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Unfolding -&gt; Unfolding
</span><a href="GHC.Types.Id.Info.html#zapUnfolding"><span class="hs-identifier hs-var">zapUnfolding</span></a></span><span> </span><span class="annot"><span class="annottext">Unfolding
</span><a href="#local-6989586621681180679"><span class="hs-identifier hs-var">unf_info</span></a></span><span>
</span><span id="line-1242"></span><span>    </span><span id="local-6989586621681180677"><span class="annot"><span class="annottext">unf_from_rhs :: Unfolding
</span><a href="#local-6989586621681180677"><span class="hs-identifier hs-var hs-var">unf_from_rhs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; UnfoldingSource -&gt; StrictSig -&gt; Expr Id -&gt; Unfolding
</span><a href="GHC.Core.Unfold.html#mkFinalUnfolding"><span class="hs-identifier hs-var">mkFinalUnfolding</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681180712"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">UnfoldingSource
</span><a href="GHC.Core.html#InlineRhs"><span class="hs-identifier hs-var">InlineRhs</span></a></span><span> </span><span class="annot"><span class="annottext">StrictSig
</span><a href="#local-6989586621681180701"><span class="hs-identifier hs-var">final_sig</span></a></span><span> </span><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180708"><span class="hs-identifier hs-var">tidy_rhs</span></a></span><span>
</span><span id="line-1243"></span><span>    </span><span class="hs-comment">-- NB: do *not* expose the worker if show_unfold is off,</span><span>
</span><span id="line-1244"></span><span>    </span><span class="hs-comment">--     because that means this thing is a loop breaker or</span><span>
</span><span id="line-1245"></span><span>    </span><span class="hs-comment">--     marked NOINLINE or something like that</span><span>
</span><span id="line-1246"></span><span>    </span><span class="hs-comment">-- This is important: if you expose the worker for a loop-breaker</span><span>
</span><span id="line-1247"></span><span>    </span><span class="hs-comment">-- then you can make the simplifier go into an infinite loop, because</span><span>
</span><span id="line-1248"></span><span>    </span><span class="hs-comment">-- in effect the unfolding is exposed.  See #1709</span><span>
</span><span id="line-1249"></span><span>    </span><span class="hs-comment">--</span><span>
</span><span id="line-1250"></span><span>    </span><span class="hs-comment">-- You might think that if show_unfold is False, then the thing should</span><span>
</span><span id="line-1251"></span><span>    </span><span class="hs-comment">-- not be w/w'd in the first place.  But a legitimate reason is this:</span><span>
</span><span id="line-1252"></span><span>    </span><span class="hs-comment">--    the function returns bottom</span><span>
</span><span id="line-1253"></span><span>    </span><span class="hs-comment">-- In this case, show_unfold will be false (we don't expose unfoldings</span><span>
</span><span id="line-1254"></span><span>    </span><span class="hs-comment">-- for bottoming functions), but we might still have a worker/wrapper</span><span>
</span><span id="line-1255"></span><span>    </span><span class="hs-comment">-- split (see Note [Worker-wrapper for bottoming functions] in</span><span>
</span><span id="line-1256"></span><span>    </span><span class="hs-comment">-- GHC.Core.Opt.WorkWrap)</span><span>
</span><span id="line-1257"></span><span>
</span><span id="line-1258"></span><span>
</span><span id="line-1259"></span><span>    </span><span class="hs-comment">--------- Arity ------------</span><span>
</span><span id="line-1260"></span><span>    </span><span class="hs-comment">-- Usually the Id will have an accurate arity on it, because</span><span>
</span><span id="line-1261"></span><span>    </span><span class="hs-comment">-- the simplifier has just run, but not always.</span><span>
</span><span id="line-1262"></span><span>    </span><span class="hs-comment">-- One case I found was when the last thing the simplifier</span><span>
</span><span id="line-1263"></span><span>    </span><span class="hs-comment">-- did was to let-bind a non-atomic argument and then float</span><span>
</span><span id="line-1264"></span><span>    </span><span class="hs-comment">-- it to the top level. So it seems more robust just to</span><span>
</span><span id="line-1265"></span><span>    </span><span class="hs-comment">-- fix it here.</span><span>
</span><span id="line-1266"></span><span>    </span><span id="local-6989586621681180703"><span class="annot"><span class="annottext">arity :: Int
</span><a href="#local-6989586621681180703"><span class="hs-identifier hs-var hs-var">arity</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Expr Id -&gt; Int
</span><a href="GHC.Core.Opt.Arity.html#exprArity"><span class="hs-identifier hs-var">exprArity</span></a></span><span> </span><span class="annot"><span class="annottext">Expr Id
</span><a href="#local-6989586621681180709"><span class="hs-identifier hs-var">orig_rhs</span></a></span><span>
</span><span id="line-1267"></span><span>
</span><span id="line-1268"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
                  Old, dead, type-trimming code
*                                                                      *
************************************************************************

We used to try to &quot;trim off&quot; the constructors of data types that are
not exported, to reduce the size of interface files, at least without
-O.  But that is not always possible: see the old Note [When we can't
trim types] below for exceptions.

Then (#7445) I realised that the TH problem arises for any data type
that we have deriving( Data ), because we can invoke
   Language.Haskell.TH.Quote.dataToExpQ
to get a TH Exp representation of a value built from that data type.
You don't even need {-# LANGUAGE TemplateHaskell #-}.

At this point I give up. The pain of trimming constructors just
doesn't seem worth the gain.  So I've dumped all the code, and am just
leaving it here at the end of the module in case something like this
is ever resurrected.


Note [When we can't trim types]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The basic idea of type trimming is to export algebraic data types
abstractly (without their data constructors) when compiling without
-O, unless of course they are explicitly exported by the user.

We always export synonyms, because they can be mentioned in the type
of an exported Id.  We could do a full dependency analysis starting
from the explicit exports, but that's quite painful, and not done for
now.

But there are some times we can't do that, indicated by the 'no_trim_types' flag.

First, Template Haskell.  Consider (#2386) this
        module M(T, makeOne) where
          data T = Yay String
          makeOne = [| Yay &quot;Yep&quot; |]
Notice that T is exported abstractly, but makeOne effectively exports it too!
A module that splices in $(makeOne) will then look for a declaration of Yay,
so it'd better be there.  Hence, brutally but simply, we switch off type
constructor trimming if TH is enabled in this module.

Second, data kinds.  Consider (#5912)
     {-# LANGUAGE DataKinds #-}
     module M() where
     data UnaryTypeC a = UnaryDataC a
     type Bug = 'UnaryDataC
We always export synonyms, so Bug is exposed, and that means that
UnaryTypeC must be too, even though it's not explicitly exported.  In
effect, DataKinds means that we'd need to do a full dependency analysis
to see what data constructors are mentioned.  But we don't do that yet.

In these two cases we just switch off type trimming altogether.

mustExposeTyCon :: Bool         -- Type-trimming flag
                -&gt; NameSet      -- Exports
                -&gt; TyCon        -- The tycon
                -&gt; Bool         -- Can its rep be hidden?
-- We are compiling without -O, and thus trying to write as little as
-- possible into the interface file.  But we must expose the details of
-- any data types whose constructors or fields are exported
mustExposeTyCon no_trim_types exports tc
  | no_trim_types               -- See Note [When we can't trim types]
  = True

  | not (isAlgTyCon tc)         -- Always expose synonyms (otherwise we'd have to
                                -- figure out whether it was mentioned in the type
                                -- of any other exported thing)
  = True

  | isEnumerationTyCon tc       -- For an enumeration, exposing the constructors
  = True                        -- won't lead to the need for further exposure

  | isFamilyTyCon tc            -- Open type family
  = True

  -- Below here we just have data/newtype decls or family instances

  | null data_cons              -- Ditto if there are no data constructors
  = True                        -- (NB: empty data types do not count as enumerations
                                -- see Note [Enumeration types] in GHC.Core.TyCon

  | any exported_con data_cons  -- Expose rep if any datacon or field is exported
  = True

  | isNewTyCon tc &amp;&amp; isFFITy (snd (newTyConRhs tc))
  = True   -- Expose the rep for newtypes if the rep is an FFI type.
           -- For a very annoying reason.  'Foreign import' is meant to
           -- be able to look through newtypes transparently, but it
           -- can only do that if it can &quot;see&quot; the newtype representation

  | otherwise
  = False
  where
    data_cons = tyConDataCons tc
    exported_con con = any (`elemNameSet` exports)
                           (dataConName con : dataConFieldLabels con)
-}</span><span>
</span><span id="line-1370"></span></pre></body></html>